
<!doctype html>
<html lang="zh" class="no-js">
  <head>
    
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1">
      
      
      
        <link rel="canonical" href="https://github.tim-wcx.ltd/mkdocs/course/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6/">
      
      
        <link rel="prev" href="../%E8%BD%AF%E4%BB%B6%E5%B7%A5%E7%A8%8B/">
      
      
        <link rel="next" href="../%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/">
      
      <link rel="icon" href="../../assets/images/favicon.png">
      <meta name="generator" content="mkdocs-1.4.3, mkdocs-material-9.1.13">
    
    
      
        <title>计算机图形学 - Tim-Wcx</title>
      
    
    
      <link rel="stylesheet" href="../../assets/stylesheets/main.85bb2934.min.css">
      
        
        <link rel="stylesheet" href="../../assets/stylesheets/palette.a6bdf11c.min.css">
      
      

    
    
    
      
        
        
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
        <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
      
    
    
    <script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce((e,_)=>(e<<5)-e+_.charCodeAt(0),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
    
      

    
    
    
  </head>
  
  
    
    
      
    
    
    
    
    <body dir="ltr" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="cyan">
  
    
    
      <script>var palette=__md_get("__palette");if(palette&&"object"==typeof palette.color)for(var key of Object.keys(palette.color))document.body.setAttribute("data-md-color-"+key,palette.color[key])</script>
    
    <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
    <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
    <label class="md-overlay" for="__drawer"></label>
    <div data-md-component="skip">
      
        
        <a href="#_1" class="md-skip">
          跳转至
        </a>
      
    </div>
    <div data-md-component="announce">
      
    </div>
    
    
      

<header class="md-header" data-md-component="header">
  <nav class="md-header__inner md-grid" aria-label="页眉">
    <a href="../.." title="Tim-Wcx" class="md-header__button md-logo" aria-label="Tim-Wcx" data-md-component="logo">
      
  
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19.5 9V1.5h-3V9h-3V1.5h-3V9h-3V1.5H4.65V9H3v1.5h18V9h-1.5m0 4.5h-3V21h-3v-7.5h-3V21h-3v-7.5H4.65V21H3v1.5h18V21h-1.5v-7.5Z"/></svg>

    </a>
    <label class="md-header__button md-icon" for="__drawer">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg>
    </label>
    <div class="md-header__title" data-md-component="header-title">
      <div class="md-header__ellipsis">
        <div class="md-header__topic">
          <span class="md-ellipsis">
            Tim-Wcx
          </span>
        </div>
        <div class="md-header__topic" data-md-component="header-topic">
          <span class="md-ellipsis">
            
              计算机图形学
            
          </span>
        </div>
      </div>
    </div>
    
      
        <form class="md-header__option" data-md-component="palette">
          
            
            
            
            <input class="md-option" data-md-color-media="" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="cyan"  aria-label="切换至夜间模式"  type="radio" name="__palette" id="__palette_1">
            
              <label class="md-header__button md-icon" title="切换至夜间模式" for="__palette_2" hidden>
                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m17.75 4.09-2.53 1.94.91 3.06-2.63-1.81-2.63 1.81.91-3.06-2.53-1.94L12.44 4l1.06-3 1.06 3 3.19.09m3.5 6.91-1.64 1.25.59 1.98-1.7-1.17-1.7 1.17.59-1.98L15.75 11l2.06-.05L18.5 9l.69 1.95 2.06.05m-2.28 4.95c.83-.08 1.72 1.1 1.19 1.85-.32.45-.66.87-1.08 1.27C15.17 23 8.84 23 4.94 19.07c-3.91-3.9-3.91-10.24 0-14.14.4-.4.82-.76 1.27-1.08.75-.53 1.93.36 1.85 1.19-.27 2.86.69 5.83 2.89 8.02a9.96 9.96 0 0 0 8.02 2.89m-1.64 2.02a12.08 12.08 0 0 1-7.8-3.47c-2.17-2.19-3.33-5-3.49-7.82-2.81 3.14-2.7 7.96.31 10.98 3.02 3.01 7.84 3.12 10.98.31Z"/></svg>
              </label>
            
          
            
            
            
            <input class="md-option" data-md-color-media="" data-md-color-scheme="slate" data-md-color-primary="black" data-md-color-accent="cyan"  aria-label="切换至日间模式"  type="radio" name="__palette" id="__palette_2">
            
              <label class="md-header__button md-icon" title="切换至日间模式" for="__palette_1" hidden>
                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 7a5 5 0 0 1 5 5 5 5 0 0 1-5 5 5 5 0 0 1-5-5 5 5 0 0 1 5-5m0 2a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0-7 2.39 3.42C13.65 5.15 12.84 5 12 5c-.84 0-1.65.15-2.39.42L12 2M3.34 7l4.16-.35A7.2 7.2 0 0 0 5.94 8.5c-.44.74-.69 1.5-.83 2.29L3.34 7m.02 10 1.76-3.77a7.131 7.131 0 0 0 2.38 4.14L3.36 17M20.65 7l-1.77 3.79a7.023 7.023 0 0 0-2.38-4.15l4.15.36m-.01 10-4.14.36c.59-.51 1.12-1.14 1.54-1.86.42-.73.69-1.5.83-2.29L20.64 17M12 22l-2.41-3.44c.74.27 1.55.44 2.41.44.82 0 1.63-.17 2.37-.44L12 22Z"/></svg>
              </label>
            
          
        </form>
      
    
    
    
      <label class="md-header__button md-icon" for="__search">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
      </label>
      <div class="md-search" data-md-component="search" role="dialog">
  <label class="md-search__overlay" for="__search"></label>
  <div class="md-search__inner" role="search">
    <form class="md-search__form" name="search">
      <input type="text" class="md-search__input" name="query" aria-label="搜索" placeholder="搜索" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
      <label class="md-search__icon md-icon" for="__search">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
      </label>
      <nav class="md-search__options" aria-label="查找">
        
        <button type="reset" class="md-search__icon md-icon" title="清空当前内容" aria-label="清空当前内容" tabindex="-1">
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg>
        </button>
      </nav>
      
    </form>
    <div class="md-search__output">
      <div class="md-search__scrollwrap" data-md-scrollfix>
        <div class="md-search-result" data-md-component="search-result">
          <div class="md-search-result__meta">
            正在初始化搜索引擎
          </div>
          <ol class="md-search-result__list" role="presentation"></ol>
        </div>
      </div>
    </div>
  </div>
</div>
    
    
  </nav>
  
</header>
    
    <div class="md-container" data-md-component="container">
      
      
        
          
            
<nav class="md-tabs" aria-label="标签" data-md-component="tabs">
  <div class="md-grid">
    <ul class="md-tabs__list">
      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../problem/%E7%BB%84%E9%98%9F%E8%AE%AD%E7%BB%83%E8%B5%9B%EF%BC%88%E5%9B%9B%EF%BC%89/" class="md-tabs__link">
        ICPC题解
      </a>
    </li>
  

      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../icpc/%E4%B8%AA%E4%BA%BA%E6%A8%A1%E6%9D%BF/" class="md-tabs__link">
        ICPC模板
      </a>
    </li>
  

      
        
  
  


  <li class="md-tabs__item">
    <a href="../../question/" class="md-tabs__link">
      ICPC题单
    </a>
  </li>

      
        
  
  
    
  


  
  
  
    <li class="md-tabs__item">
      <a href="../%E5%9B%BE%E4%BC%98%E7%AE%97%E6%B3%95%E7%AC%94%E8%AE%B0/" class="md-tabs__link md-tabs__link--active">
        课程复习
      </a>
    </li>
  

      
        
  
  


  
  
  
    <li class="md-tabs__item">
      <a href="../../csdn/2020-08-01/" class="md-tabs__link">
        csdn导出
      </a>
    </li>
  

      
        
  
  


  <li class="md-tabs__item">
    <a href="../../plan/" class="md-tabs__link">
      个人计划
    </a>
  </li>

      
        
  
  


  <li class="md-tabs__item">
    <a href="../../about/" class="md-tabs__link">
      关于
    </a>
  </li>

      
    </ul>
  </div>
</nav>
          
        
      
      <main class="md-main" data-md-component="main">
        <div class="md-main__inner md-grid">
          
            
              
              <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    

  


<nav class="md-nav md-nav--primary md-nav--lifted" aria-label="导航栏" data-md-level="0">
  <label class="md-nav__title" for="__drawer">
    <a href="../.." title="Tim-Wcx" class="md-nav__button md-logo" aria-label="Tim-Wcx" data-md-component="logo">
      
  
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19.5 9V1.5h-3V9h-3V1.5h-3V9h-3V1.5H4.65V9H3v1.5h18V9h-1.5m0 4.5h-3V21h-3v-7.5h-3V21h-3v-7.5H4.65V21H3v1.5h18V21h-1.5v-7.5Z"/></svg>

    </a>
    Tim-Wcx
  </label>
  
  <ul class="md-nav__list" data-md-scrollfix>
    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
      
      
      <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_1" >
      
      
      
        <label class="md-nav__link" for="__nav_1" id="__nav_1_label" tabindex="0">
          ICPC题解
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_1_label" aria-expanded="false">
        <label class="md-nav__title" for="__nav_1">
          <span class="md-nav__icon md-icon"></span>
          ICPC题解
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E7%BB%84%E9%98%9F%E8%AE%AD%E7%BB%83%E8%B5%9B%EF%BC%88%E5%9B%9B%EF%BC%89/" class="md-nav__link">
        组队训练赛（四）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E7%BB%84%E9%98%9F%E8%AE%AD%E7%BB%83%E8%B5%9B%EF%BC%88%E4%B8%89%EF%BC%89/" class="md-nav__link">
        组队训练赛（三）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E7%BB%84%E9%98%9F%E8%AE%AD%E7%BB%83%E8%B5%9B%EF%BC%88%E4%BA%8C%EF%BC%89/" class="md-nav__link">
        组队训练赛（二）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E7%BB%84%E9%98%9F%E8%AE%AD%E7%BB%83%E8%B5%9B%EF%BC%88%E4%B8%80%EF%BC%89/" class="md-nav__link">
        组队训练赛（一）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E7%B3%BB%E5%88%97%E9%A2%98%E8%A7%A3%EF%BC%88%E5%8D%81%E4%BA%94%EF%BC%89/" class="md-nav__link">
        暑假集训系列题解（十五）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E7%B3%BB%E5%88%97%E9%A2%98%E8%A7%A3%EF%BC%88%E5%8D%81%E5%9B%9B%EF%BC%89/" class="md-nav__link">
        暑假集训系列题解（十四）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E7%B3%BB%E5%88%97%E9%A2%98%E8%A7%A3%EF%BC%88%E5%8D%81%E4%B8%89%EF%BC%89/" class="md-nav__link">
        暑假集训系列题解（十三）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E7%B3%BB%E5%88%97%E9%A2%98%E8%A7%A3%EF%BC%88%E5%8D%81%E4%BA%8C%EF%BC%89/" class="md-nav__link">
        暑假集训系列题解（十二）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E7%B3%BB%E5%88%97%E9%A2%98%E8%A7%A3%EF%BC%88%E5%8D%81%E4%B8%80%EF%BC%89/" class="md-nav__link">
        暑假集训系列题解（十一）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E7%B3%BB%E5%88%97%E9%A2%98%E8%A7%A3%EF%BC%88%E5%8D%81%EF%BC%89/" class="md-nav__link">
        暑假集训系列题解（十）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E7%B3%BB%E5%88%97%E9%A2%98%E8%A7%A3%EF%BC%88%E4%B9%9D%EF%BC%89/" class="md-nav__link">
        暑假集训系列题解（九）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E7%B3%BB%E5%88%97%E9%A2%98%E8%A7%A3%EF%BC%88%E5%85%AB%EF%BC%89/" class="md-nav__link">
        暑假集训系列题解（八）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E7%B3%BB%E5%88%97%E9%A2%98%E8%A7%A3%EF%BC%88%E4%B8%83%EF%BC%89/" class="md-nav__link">
        暑假集训系列题解（七）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E7%B3%BB%E5%88%97%E9%A2%98%E8%A7%A3%EF%BC%88%E5%85%AD%EF%BC%89/" class="md-nav__link">
        暑假集训系列题解（六）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E7%B3%BB%E5%88%97%E9%A2%98%E8%A7%A3%EF%BC%88%E4%BA%94%EF%BC%89/" class="md-nav__link">
        暑假集训系列题解（五）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E7%B3%BB%E5%88%97%E9%A2%98%E8%A7%A3%EF%BC%88%E5%9B%9B%EF%BC%89/" class="md-nav__link">
        暑假集训系列题解（四）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E7%B3%BB%E5%88%97%E9%A2%98%E8%A7%A3%EF%BC%88%E4%B8%89%EF%BC%89/" class="md-nav__link">
        暑假集训系列题解（三）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E7%B3%BB%E5%88%97%E9%A2%98%E8%A7%A3%EF%BC%88%E4%BA%8C%EF%BC%89/" class="md-nav__link">
        暑假集训系列题解（二）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/%E6%9A%91%E5%81%87%E9%9B%86%E8%AE%AD%E9%A2%98%E8%A7%A3%E7%B3%BB%E5%88%97%EF%BC%88%E4%B8%80%EF%BC%89/" class="md-nav__link">
        暑假集训题解系列（一）
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-02-02-2%E6%9C%882%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-02-02-2月2日题解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-02-07-2%E6%9C%887%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-02-07-2月7日题解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-02-02-2%E6%9C%882%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-02-02-2月2日题解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-02-07-2%E6%9C%887%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-02-07-2月7日题解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-02-08-2%E6%9C%888%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-02-08-2月8日题解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-02-09-2%E6%9C%889%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-02-09-2月9日题解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-02-12-%E5%AE%89%E5%8D%93%E8%AF%BE%E8%A1%A8%E5%AE%A2%E6%88%B7%E7%AB%AF%2B%E6%9C%8D%E5%8A%A1%E7%AB%AF%E6%B3%A8%E8%A7%A3/" class="md-nav__link">
        2021-02-12-安卓课表客户端+服务端注解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-02-16-2%E6%9C%8816%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-02-16-2月16日题解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-02-19-2%E6%9C%8819%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-02-19-2月19日题解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-02-20-2%E6%9C%8820%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-02-20-2月20日题解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-02-22-2%E6%9C%8822%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-02-22-2月22日题解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-02-24-2%E6%9C%8824%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-02-24-2月24日题解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-02-28-2%E6%9C%8828%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-02-28-2月28日题解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-03-02-3%E6%9C%882%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-03-02-3月2日题解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-03-07-3%E6%9C%887%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-03-07-3月7日题解
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-03-09-%E6%95%B0%E8%AE%BA/" class="md-nav__link">
        2021-03-09-数论
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../problem/2021-06-05-6%E6%9C%885%E6%97%A5%E9%A2%98%E8%A7%A3/" class="md-nav__link">
        2021-06-05-6月5日题解
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
      
      
      <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_2" >
      
      
      
        <label class="md-nav__link" for="__nav_2" id="__nav_2_label" tabindex="0">
          ICPC模板
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_2_label" aria-expanded="false">
        <label class="md-nav__title" for="__nav_2">
          <span class="md-nav__icon md-icon"></span>
          ICPC模板
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../icpc/%E4%B8%AA%E4%BA%BA%E6%A8%A1%E6%9D%BF/" class="md-nav__link">
        个人模板
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../icpc/kuangbin%E6%A8%A1%E6%9D%BF/" class="md-nav__link">
        kuangbin模板
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    <li class="md-nav__item">
      <a href="../../question/" class="md-nav__link">
        ICPC题单
      </a>
    </li>
  

    
      
      
      

  
  
    
  
  
    
    <li class="md-nav__item md-nav__item--active md-nav__item--nested">
      
      
      
      
      <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4" checked>
      
      
      
        <label class="md-nav__link" for="__nav_4" id="__nav_4_label" tabindex="0">
          课程复习
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_4_label" aria-expanded="true">
        <label class="md-nav__title" for="__nav_4">
          <span class="md-nav__icon md-icon"></span>
          课程复习
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../%E5%9B%BE%E4%BC%98%E7%AE%97%E6%B3%95%E7%AC%94%E8%AE%B0/" class="md-nav__link">
        图优算法笔记
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../%E5%8D%9A%E6%B5%81WIFI%E8%B5%84%E6%96%99/" class="md-nav__link">
        博流WIFI资料
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../%E6%95%B0%E5%AD%97%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86/" class="md-nav__link">
        数字图像处理
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../%E7%8E%B0%E4%BB%A3%E5%AF%86%E7%A0%81%E5%AD%A6/" class="md-nav__link">
        现代密码学
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../%E8%BD%AF%E4%BB%B6%E5%B7%A5%E7%A8%8B/" class="md-nav__link">
        软件工程
      </a>
    </li>
  

            
          
            
              
  
  
    
  
  
    <li class="md-nav__item md-nav__item--active">
      
      <input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
      
      
        
      
      
        <label class="md-nav__link md-nav__link--active" for="__toc">
          计算机图形学
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <a href="./" class="md-nav__link md-nav__link--active">
        计算机图形学
      </a>
      
        

<nav class="md-nav md-nav--secondary" aria-label="目录">
  
  
  
    
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      目录
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#_2" class="md-nav__link">
    第一章 绪论
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_3" class="md-nav__link">
    第二章 计算机图形系统概述
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_4" class="md-nav__link">
    第三章  基本光栅图形生成技术
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_5" class="md-nav__link">
    第四章 几何变换
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_6" class="md-nav__link">
    第五章 二维图形的显示
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_7" class="md-nav__link">
    第六章 三维图形的显示
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_8" class="md-nav__link">
    第八章   真实感图形生成
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_9" class="md-nav__link">
    第九章  曲线与曲面
  </a>
  
</li>
      
    </ul>
  
</nav>
      
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/" class="md-nav__link">
        计算机操作系统
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../%E5%8D%95%E7%89%87%E6%9C%BA/" class="md-nav__link">
        单片机
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../PDF%E5%88%92%E8%AF%8D%E7%BF%BB%E8%AF%91/" class="md-nav__link">
        PDF划词翻译
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../make/" class="md-nav__link">
        makefile学习笔记
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../RT_Smart%E4%B8%ADminizip%E7%A7%BB%E6%A4%8D%E8%AE%B0%E5%BD%95/" class="md-nav__link">
        RT_Smart中minizip移植记录
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
      
      
      <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5" >
      
      
      
        <label class="md-nav__link" for="__nav_5" id="__nav_5_label" tabindex="0">
          csdn导出
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_5_label" aria-expanded="false">
        <label class="md-nav__title" for="__nav_5">
          <span class="md-nav__icon md-icon"></span>
          csdn导出
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-01/" class="md-nav__link">
        2020-08-01
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-02%E7%BA%BF%E6%AE%B5%E6%A0%91/" class="md-nav__link">
        2020-08-02线段树
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-03/" class="md-nav__link">
        2020-08-03
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-04/" class="md-nav__link">
        2020-08-04
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-05/" class="md-nav__link">
        2020-08-05
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-06%E7%BA%BF%E6%AE%B5%E6%A0%91/" class="md-nav__link">
        2020-08-06线段树
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-07/" class="md-nav__link">
        2020-08-07
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-08/" class="md-nav__link">
        2020-08-08
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-09/" class="md-nav__link">
        2020-08-09
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-10/" class="md-nav__link">
        2020-08-10
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-11/" class="md-nav__link">
        2020-08-11
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-12%E6%AC%A7%E6%8B%89%E5%87%BD%E6%95%B0/" class="md-nav__link">
        2020-08-12欧拉函数
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-13/" class="md-nav__link">
        2020-08-13
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-14/" class="md-nav__link">
        2020-08-14
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-16%E6%A0%91%E5%BD%A2DP%E7%AD%89%E5%B7%AE%E6%95%B0%E5%88%97%E5%89%8D%E7%BC%80%E5%92%8C/" class="md-nav__link">
        2020-08-16树形DP等差数列前缀和
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-17/" class="md-nav__link">
        2020-08-17
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-18/" class="md-nav__link">
        2020-08-18
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-19/" class="md-nav__link">
        2020-08-19
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-20/" class="md-nav__link">
        2020-08-20
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-08-21/" class="md-nav__link">
        2020-08-21
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-09-05%E5%88%92%E5%88%86%E6%A0%91%E6%B1%82%E6%9F%90%E4%B8%80%E5%8C%BA%E9%97%B4%E7%9A%84%E4%B8%AD%E4%BD%8D%E6%95%B0/" class="md-nav__link">
        2020-09-05划分树求某一区间的中位数
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-09-07/" class="md-nav__link">
        2020-09-07
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-09-08%E4%BA%8C%E5%88%86%E6%9C%80%E5%B0%8F%E7%94%9F%E6%88%90%E6%A0%91/" class="md-nav__link">
        2020-09-08二分最小生成树
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-09-08%E6%95%B0%E4%BD%8DDP%E4%BA%8C%E5%88%86/" class="md-nav__link">
        2020-09-08数位DP二分
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-09-09%E6%95%B0%E4%BD%8DDP/" class="md-nav__link">
        2020-09-09数位DP
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-09-11%E6%A0%91%E7%8A%B6%E6%95%B0%E7%BB%84%E6%B1%82%E6%9C%80%E5%A4%A7%E5%80%BC/" class="md-nav__link">
        2020-09-11树状数组求最大值
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-09-12%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%93%88%E5%B8%8C/" class="md-nav__link">
        2020-09-12字符串哈希
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-09-12/" class="md-nav__link">
        2020-09-12
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-09-21%E5%87%B8%E5%8C%85%E7%AE%97%E6%B3%95/" class="md-nav__link">
        2020-09-21凸包算法
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-09-23%E6%A0%91%E7%8A%B6%E6%95%B0%E7%BB%84/" class="md-nav__link">
        2020-09-23树状数组
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-09-26%E6%9C%80%E5%B0%8F%E8%B4%B9%E7%94%A8%E6%9C%80%E5%A4%A7%E6%B5%81%E9%97%AE%E9%A2%98/" class="md-nav__link">
        2020-09-26最小费用最大流问题
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-10-04%E7%BA%BF%E6%AE%B5%E6%A0%91%E6%89%AB%E6%8F%8F%E7%BA%BF/" class="md-nav__link">
        2020-10-04线段树扫描线
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-10-05/" class="md-nav__link">
        2020-10-05
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-10-07%E5%B9%B6%E6%9F%A5%E9%9B%86%E5%90%AF%E5%8F%91%E5%BC%8F%E5%90%88%E5%B9%B6/" class="md-nav__link">
        2020-10-07并查集启发式合并
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-10-15dsuontree/" class="md-nav__link">
        2020-10-15dsuontree
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-11-23/" class="md-nav__link">
        2020-11-23
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-12-02/" class="md-nav__link">
        2020-12-02
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2020-7-31/" class="md-nav__link">
        2020-7-31
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2021-02-02/" class="md-nav__link">
        2021-02-02
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/2021-02-24/" class="md-nav__link">
        2021-02-24
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/Beyond_compare4_30%E5%A4%A9%E8%AF%95%E7%94%A8%E8%BF%87%E6%9C%9F/" class="md-nav__link">
        Beyondcompare430天试用过期
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/GitHub%E5%8D%9A%E5%AE%A2/" class="md-nav__link">
        GitHub博客
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/%E4%BA%8C%E5%88%86%E4%BA%8C%E5%88%86%E6%9F%A5%E6%89%BE%E6%A8%A1%E6%9D%BF/" class="md-nav__link">
        二分二分查找模板
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/%E5%BC%82%E6%88%96%E6%B1%82%E5%92%8C%E5%BC%8F/" class="md-nav__link">
        异或求和式
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/%E6%B1%82%E7%BB%84%E5%90%88%E6%95%B0%E7%9A%84%E6%96%B9%E6%B3%95/" class="md-nav__link">
        求组合数的方法
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/%E6%B1%82%E9%80%86%E5%BA%8F%E5%AF%B9/" class="md-nav__link">
        求逆序对
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/%E7%AE%80%E4%BB%8B%E6%89%A9%E5%B1%95%E6%AC%A7%E5%87%A0%E9%87%8C%E5%BE%B7%E5%AE%9A%E7%90%86/" class="md-nav__link">
        简介扩展欧几里德定理
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../csdn/%E9%93%BE%E8%A1%A8/" class="md-nav__link">
        链表
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    <li class="md-nav__item">
      <a href="../../plan/" class="md-nav__link">
        个人计划
      </a>
    </li>
  

    
      
      
      

  
  
  
    <li class="md-nav__item">
      <a href="../../about/" class="md-nav__link">
        关于
      </a>
    </li>
  

    
  </ul>
</nav>
                  </div>
                </div>
              </div>
            
            
              
              <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    

<nav class="md-nav md-nav--secondary" aria-label="目录">
  
  
  
    
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      目录
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#_2" class="md-nav__link">
    第一章 绪论
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_3" class="md-nav__link">
    第二章 计算机图形系统概述
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_4" class="md-nav__link">
    第三章  基本光栅图形生成技术
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_5" class="md-nav__link">
    第四章 几何变换
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_6" class="md-nav__link">
    第五章 二维图形的显示
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_7" class="md-nav__link">
    第六章 三维图形的显示
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_8" class="md-nav__link">
    第八章   真实感图形生成
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#_9" class="md-nav__link">
    第九章  曲线与曲面
  </a>
  
</li>
      
    </ul>
  
</nav>
                  </div>
                </div>
              </div>
            
          
          
            <div class="md-content" data-md-component="content">
              <article class="md-content__inner md-typeset">
                
                  


<h1 id="_1">计算机图形学复习<a class="headerlink" href="#_1" title="Permanent link">&para;</a></h1>
<h3 id="_2">第一章 绪论<a class="headerlink" href="#_2" title="Permanent link">&para;</a></h3>
<p><strong>定义</strong></p>
<p>计算机图形学是研究通过计算机将数据转换为图形，并在专门的显示设备上显示的原理、方法和技术的学科。</p>
<p>计算机图形学就是应用计算机技术进行图形的生成、处理和输出。</p>
<p>计算机图形学与其他学科的关系</p>
<p><img alt="image-20211210185332425" src="https://pic.tim-wcx.ltd//img/20211210185332.png" /></p>
<p><strong>图形的基本要素</strong></p>
<p>几何要素，刻画对象的轮廓、形状等。如点，线，多边形，多面体等；</p>
<p>非几何要素，刻画对象的颜色、材质等。如颜色，纹理等。</p>
<p><strong>图形表示 存储方法</strong></p>
<ol>
<li>点阵法</li>
</ol>
<p>枚举出图形中所有的点(强调由点&lt;像素&gt;构成），这种表示的图形称为图像。</p>
<ol>
<li>参数法</li>
</ol>
<p>由图形的形状参数(方程或表达式的系数，线段的端点坐标等) + 属性参数(颜色、线型等) )来表示图形，称为图形（graphics），如圆可用半径、圆心坐标和颜色表示</p>
<p><strong>计算机图形学基本研究内容</strong></p>
<p>1、图形系统（硬、软、标准化）</p>
<p>2、基本图形生成：如何显示点、线段、多边形及圆等几何图形</p>
<p>3、图形的处理：几何变换（图形动起来）；投影变换（如何显示三维图形）；真实感图形（光照、阴影。。。）</p>
<p>4、物体造型：实体表示；曲线曲面；真实感</p>
<h3 id="_3">第二章 计算机图形系统概述<a class="headerlink" href="#_3" title="Permanent link">&para;</a></h3>
<p><strong>计算机图形系统</strong></p>
<ol>
<li>
<p>组成</p>
</li>
<li>
<p>硬件与软件示意图</p>
<p><img alt="image-20211206223937534" src="https://pic.tim-wcx.ltd//img/20211206223939.png" /></p>
</li>
<li>
<p>硬件：输入设备、输出设备、存储设备、图形处理设备</p>
</li>
<li>
<p>软件：软件包、应用程序、应用模型</p>
</li>
<li>
<p>基本功能</p>
</li>
<li>
<p>计算：图形处理（如图形变换、光照等）</p>
</li>
<li>存储：远程和本机</li>
<li>输入：人机交互及数据文件等</li>
<li>输出：显示器、打印机等</li>
<li>对话图形：人机交互</li>
</ol>
<p><strong>显示设备</strong></p>
<ol>
<li>两种设备</li>
<li>
<p>阴极射线管CRT (Cathode Ray Tube)</p>
<p>特点：亮度高、对比度好、色彩鲜艳</p>
<p>缺点：体积大，笨重</p>
</li>
<li>
<p>平板型显示器：液晶、等离子</p>
<p>特点：器件薄，适合便携</p>
<p>缺点：亮度和对比度相对较低、色彩不够鲜艳，价格偏高</p>
</li>
<li>
<p>CRT</p>
</li>
<li>
<p>基本原理</p>
<p>一种真空器件，它利用电磁场产生高速的、经过聚焦的电子束，偏转到屏幕的不同位置，轰击屏幕表面的荧光材料，从而产生可见的图形</p>
</li>
<li>
<p>组成</p>
<p>电子枪、聚焦系统、加速电极、偏转系统、荧光屏</p>
</li>
<li>
<p>电子枪
      电灯丝，阴极和控制栅组成</p>
<p>灯丝：产生热量</p>
<p>阴极：由灯丝加热发出电子束</p>
<p>控制栅：加上负电压后，能够控制通过其中小孔的带负电的电子束的强弱。通过调节负电压高低来控制电子数量，即控制荧光屏上相应点的亮度</p>
</li>
<li>
<p>电子枪
      电灯丝，阴极和控制栅组成</p>
<p>灯丝：产生热量</p>
<p>阴极：由灯丝加热发出电子束</p>
</li>
<li>
<p>控制栅</p>
<p>加上负电压后，能够控制通过其中小孔的带负电的电子束的强弱。通过调节负电压高低来控制电子数量，即控制荧光屏上相应点的亮度</p>
</li>
<li>
<p>加速电极 加正的高压电（几万伏） 使电子束高速运动</p>
</li>
<li>
<p>偏转系统</p>
<p>控制电子束，静电场或磁场，产生偏转</p>
<p>最大偏转角是衡量系统性能的最重要的指标，显示器长短与此有关</p>
</li>
<li>
<p>荧光屏
      荧光物质：吸收电子束而发光</p>
<p>持续发光时间：电子束离开某点后，该点的亮度值衰减到初始值1/10 所需的时间</p>
<p>刷新(Refresh)：为了让荧光物质保持一个稳定的亮度值</p>
<p>刷新频率：每秒钟重绘屏幕的次数</p>
<p>CRT产生稳定图像所需要的最小刷新频率=1秒/荧光物质的持续发光时间</p>
<p>例：荧光物质的持续发光时间40毫秒，刷新频率就是 1000/40=25Hz</p>
</li>
<li>
<p>彩色CRT</p>
</li>
<li>
<p>射线穿透法</p>
<p>原理：两层荧光涂层，红色光和绿色光两种发光物质，电子束轰击穿透荧光层的深浅，决定所产生的颜色</p>
<p>应用：主要用于画线显示器</p>
<p>特点：优点是成本低；缺点是只能产生有限几种颜色</p>
</li>
<li>
<p>影孔板法
      应用：主要用于光栅扫描显示器</p>
<p>结构：外层玻璃、荧光涂层和影孔板，影孔板被安装在荧光屏的内表面，用于精确定位像素的位置</p>
<p>工作原理：每个像素处有3个荧光点，呈三角形排列。三支电子枪对应红、绿、蓝三基色。电子枪、影孔板中的一个小孔和荧光点呈一直线；每个小孔与一个像素（即三个荧光点）对应。</p>
<p>亮度调节：各电子枪发生的电子数目，可控制各色光点亮度</p>
</li>
<li>
<p>液晶显示器LCD</p>
</li>
</ol>
<p>在液晶分子两端所加电压的不同，液晶分子的翻转程 度不同，根据液晶角度的不同透过光的偏振性也不同；</p>
<p>液晶可以被光穿透，并影响光的偏振性；</p>
<p>液晶的电光效应：当液晶分子的某种排列状态在电场作用下变为另一种排列状态时，液晶的光学性质随之改变。</p>
<p>液晶显示的机理：通过能阻塞或传递光的液晶材料，传递来自周围的或内部光源的偏振光</p>
<p>组成：光源、垂直偏光板、玻璃电极、液晶、玻璃电极、水平偏光板</p>
<ol>
<li>
<p>比较</p>
</li>
<li>
<p>共同特点</p>
<div class="codehilite"><pre><span></span><code> 都是通过单个发光元素（点，像素）来显示图形或文字。
</code></pre></div>

</li>
<li>
<p>不同点</p>
<p>（1）LCD体积小，厚度薄，重量轻，耗能少，辐射很少。（2）CRT显示亮度高，色彩鲜艳，分辨率高。</p>
</li>
</ol>
<p><strong>性能指标</strong></p>
<p>像素(Pixel: Picture Cell)：构成屏幕（图像）的最小元素</p>
<p>分辨率(Resolution)：CRT在水平或竖直方向单位长度上能识别的最大像素个数，单位通常为dpi（dots per inch)</p>
<p>分辨率越高显示的图形就越精细</p>
<p><strong>显示系统</strong></p>
<ol>
<li>主要组成</li>
</ol>
<p>显示设备：显示器</p>
<p>视频控制器：控制显示设备（有的含图形加速处理器），通过访问帧缓存来刷新屏幕</p>
<p>显示缓冲存储器（帧缓存）：可以在内存或显示控制器中</p>
<p><img alt="image-20211206225420561" src="https://pic.tim-wcx.ltd//img/20211206225420.png" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211206225721.png" alt="image-20211206225720957" style="zoom: 80%;" /></p>
<ol>
<li>
<p>显示系统</p>
</li>
<li>
<p>随机扫描（random scan）：电子束可以任意移动。画线设备</p>
<p>特点：电子束可随意移动，只扫描荧屏上要显示的部分像素、对应的显示器为画线设备</p>
<p>逻辑部件：刷新存储器(Refreshing Buffer)、显示处理器（DPU: Display Processing Unit、CRT</p>
</li>
<li>
<p>光栅扫描（raster scan）：电子束按固定扫描线和次序进行。画点设备</p>
<ol>
<li>
<p>基本概念</p>
<p>基本原理：电子束按固定的扫描线和扫描顺序从左到右、自上而下进行扫描。</p>
<p>基本概念：扫描线：一条水平线 帧（frame）：1次扫描生成的图像</p>
<p>水平回扫期：水平线间的回扫期 垂直回扫期：帧间的回扫期</p>
</li>
<li>
<p>组成
      帧缓冲存储器（Frame Buffer)--帧缓存</p>
<p>视频控制器（Video Controller)</p>
<p>显示处理器（Display Processor）</p>
<p>显示器：CRT、液晶</p>
</li>
<li>
<p>帧缓存</p>
<p>作用：存储屏幕上像素的颜色值</p>
<p>帧缓存中单元数目与显示器上像素的数目相同，单元与像素一一对应，各单元的数值决定了其对应像素的颜色。</p>
<p>显示颜色的种类与帧缓存中每个单元的位数有关。如：黑白显示系统的帧缓冲器的每个单元只需一位。</p>
<p>帧缓存容量：分辨率M*N、颜色个数K 与缓存大小V 的关系 $V \geq M*N* \lceil log_2 K \rceil $</p>
<p>目前有的PC机的显存容量达512M以上，有必要？</p>
<p>原因：显存还包括深度缓存、纹理内存等</p>
</li>
<li>
<p>颜色模型 三基色</p>
<p>RGB三基色：面向硬件设备（摄像机、扫描仪和投影仪等）</p>
<p>CMY三基色：三补色： 蓝绿(C, cyan)，品红(M, magenta)，黄(Y, yellow) 用于彩色打印</p>
<p>CMY与RGB关系：R=1-C、G=1-M、B=1-Y</p>
</li>
<li>
<p>视频控制器</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211206230352.png" alt="image-20211206230351943" style="zoom:50%;" /></p>
</li>
<li>
<p>显示处理器</p>
<p>作用：代替CPU完成部分图形处理功能，扫描转换、几何变换、裁剪、光栅操作、纹理映射等等</p>
<p>具有专用显示处理器的光栅显示系统的结构</p>
<p>图形加速卡 = 视频控制器 + 显存 + 显示处理器</p>
<p>显卡=显示处理器的专用存储器+帧缓冲器+视频控制器+显示处理器</p>
<p><img alt="image-20211206230818600" src="https://pic.tim-wcx.ltd//img/20211206230818.png" /></p>
</li>
<li>
<p>特点
      优点：成本低、易于绘制填充图形、色彩丰富、刷新频率一定、与图形的复杂程度无关、易于修改图形</p>
<p>缺点：需要扫描转换，复杂图形计算量大、会产生混淆（走样）</p>
</li>
</ol>
</li>
</ol>
<p><strong>软件系统</strong></p>
<ol>
<li>第一层次：面向硬件系统</li>
</ol>
<p>解决图形设备与计算机的通讯接口等问题，称为设备驱动程序</p>
<p>设备驱动程序现在已被作为操作系统一部分，由操作系统或设备硬件厂商开发； </p>
<ol>
<li>第二层次：建立在驱动程序之上</li>
</ol>
<p>完成图元的生成、设备的管理等功能</p>
<p>这个层次上的图形支撑软件已经标准化，如GKS、PHIGS、CGI等； </p>
<ol>
<li>第三层次：面向用户</li>
</ol>
<p>主要任务是建立图形数据结构，定义、修改和输出图形</p>
<p>具有较强的交互功能，使用方便，容易阅读，便于维护和移植</p>
<p>OpenGL、Direct3D属于这一层次</p>
<h3 id="_4">第三章  基本光栅图形生成技术<a class="headerlink" href="#_4" title="Permanent link">&para;</a></h3>
<p><strong>光栅图形学</strong></p>
<ol>
<li>图元的生成</li>
</ol>
<p>是指完成图元的参数表示形式到点阵表示形式的转换。通常也称扫描转换图元(Scan Converter) </p>
<p>参数表示形式由不同种类图形的性质决定，点阵表示形式是光栅显示系统刷新时所需的表示形式。</p>
<ol>
<li>openGL相关函数</li>
</ol>
<div class="language-c highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="c1">//初始化颜色</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a><span class="n">glClearColor</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">);</span><span class="w"> </span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a><span class="c1">//清除帧缓存，并将每个像素对应单元赋为背景颜色值</span>
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a><span class="n">glClear</span><span class="p">(</span><span class="w"> </span><span class="n">GL_COLOR_BUFFER_BIT</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">GL_DEPTH_BUFFER_BIT</span><span class="w"> </span><span class="p">);</span><span class="w"> </span>
</span><span id="__span-0-5"><a id="__codelineno-0-5" name="__codelineno-0-5" href="#__codelineno-0-5"></a><span class="c1">//表示结束绘图命令，使用单缓存时必须要。双缓冲时可以不要</span>
</span><span id="__span-0-6"><a id="__codelineno-0-6" name="__codelineno-0-6" href="#__codelineno-0-6"></a><span class="n">glFinish</span><span class="p">();</span>
</span><span id="__span-0-7"><a id="__codelineno-0-7" name="__codelineno-0-7" href="#__codelineno-0-7"></a><span class="c1">//双缓存时使用。交换缓存命令，表示当前显示帧和下帧的帧缓存交换</span>
</span><span id="__span-0-8"><a id="__codelineno-0-8" name="__codelineno-0-8" href="#__codelineno-0-8"></a><span class="n">glutSwapBuffers</span><span class="p">();</span>
</span></code></pre></div>
<ol>
<li>单缓存与双缓存机制</li>
</ol>
<p>单缓存：扫描与生成点阵串行进行</p>
<p>双缓存：扫描与生成点阵同时（并行）进行</p>
<p><strong>基本线画图元生成</strong></p>
<ol>
<li>
<p>扫描转换直线段</p>
</li>
<li>
<p>概念：求与直线段充分接近的像素集，并以此像素集替代原连续直线段在屏幕上显示。</p>
</li>
<li>
<p>约束条件：</p>
<p>屏幕坐标系是整型坐标系、像素间横向和纵向距离相等、直线段为<span class="arithmatex"><span class="MathJax_Preview">P_0(x_0,y_0)，p_1(x_1,y_1且 x_0&lt;x_1且均为整数)</span><script type="math/tex">P_0(x_0,y_0)，p_1(x_1,y_1且 x_0<x_1且均为整数)</script></span>、直线段的宽度（线宽）为1【横向或纵向像素相邻】、</p>
<p>直线段的斜率<span class="arithmatex"><span class="MathJax_Preview">0 \leq k \leq 1</span><script type="math/tex">0 \leq k \leq 1</script></span>、相邻像素间坐标分量差为-1，0或1</p>
</li>
<li>
<p>主要算法</p>
<ol>
<li>
<p>直线方程法</p>
<ol>
<li>
<p>基本思想</p>
<p>根据直线的几何方程确定线段路径上的像素位置。</p>
</li>
<li>
<p>方法</p>
<p>划分区间<span class="arithmatex"><span class="MathJax_Preview">[x_0, x_1]</span><script type="math/tex">[x_0, x_1]</script></span>: <span class="arithmatex"><span class="MathJax_Preview">t_0, t_1,…, t_n,  t_{i+1}=x_{i+1}</span><script type="math/tex">t_0, t_1,…, t_n,  t_{i+1}=x_{i+1}</script></span>,  其中<span class="arithmatex"><span class="MathJax_Preview">t_{i+1}=t_i+1,t_0 = x_0,t_n=x_1</span><script type="math/tex">t_{i+1}=t_i+1,t_0 = x_0,t_n=x_1</script></span></p>
<p>计算纵坐标y：<span class="arithmatex"><span class="MathJax_Preview">y_i = k*t_i + b</span><script type="math/tex">y_i = k*t_i + b</script></span></p>
<p>取整：四舍五入，即<span class="arithmatex"><span class="MathJax_Preview">y_{i,r}=round(y_i)=(int)(y_i+0.5)</span><script type="math/tex">y_{i,r}=round(y_i)=(int)(y_i+0.5)</script></span></p>
</li>
<li>
<p>主要运算：乘法+加法+取整+浮点运算</p>
</li>
</ol>
</li>
<li>
<p>数值微分DDA算法、</p>
<ol>
<li>方法：<span class="arithmatex"><span class="MathJax_Preview">y_{i+1}=k*x_{i+1}+b=k*(x_i+1)+b=y_i+k</span><script type="math/tex">y_{i+1}=k*x_{i+1}+b=k*(x_i+1)+b=y_i+k</script></span></li>
<li>主要运算：加法+取整+浮点运算</li>
</ol>
</li>
<li>
<p>中点算法</p>
<ol>
<li>
<p>目标：消除浮点运算</p>
</li>
<li>
<p>方法</p>
<ol>
<li>直线隐式方程</li>
</ol>
<p><span class="arithmatex"><span class="MathJax_Preview">F(x,y)=a*x+b*y+c=0</span><script type="math/tex">F(x,y)=a*x+b*y+c=0</script></span></p>
<p>可根据<span class="arithmatex"><span class="MathJax_Preview">F(x,y)</span><script type="math/tex">F(x,y)</script></span>的大小来判断点是否在直线和点的关系：</p>
<p><span class="arithmatex"><span class="MathJax_Preview">F(x,y)&gt;0</span><script type="math/tex">F(x,y)>0</script></span>直线上方，<span class="arithmatex"><span class="MathJax_Preview">F(x,y)=0</span><script type="math/tex">F(x,y)=0</script></span>直线上，<span class="arithmatex"><span class="MathJax_Preview">F(x,y)&lt;0</span><script type="math/tex">F(x,y)<0</script></span>直线下方</p>
<ol>
<li>判断下一个像素点的坐标</li>
</ol>
<p>已计算出某一点的坐标<span class="arithmatex"><span class="MathJax_Preview">(x_i,y_{i,r})</span><script type="math/tex">(x_i,y_{i,r})</script></span>，则可构造判别式<span class="arithmatex"><span class="MathJax_Preview">d=F(M)=F(x_{i+1},y_{i,r}+0.5)</span><script type="math/tex">d=F(M)=F(x_{i+1},y_{i,r}+0.5)</script></span>，通过d的正负来判断下一点的坐标，若d&lt;0，则选择<span class="arithmatex"><span class="MathJax_Preview">(x_{i+1},y_{i,r}+1)</span><script type="math/tex">(x_{i+1},y_{i,r}+1)</script></span>，反之，选择<span class="arithmatex"><span class="MathJax_Preview">(x_{i+1},y_{i,r})</span><script type="math/tex">(x_{i+1},y_{i,r})</script></span>。</p>
<ol>
<li>
<p>判断再下一个像素点的坐标</p>
</li>
<li>
<p>若<span class="arithmatex"><span class="MathJax_Preview">d \geq 0 <span class="arithmatex"><span class="MathJax_Preview">，则取右侧像素</span><script type="math/tex">，则取右侧像素</script></span>(x_{i+1},y_{i,r})(x_{i+1},y_{i,r})</span><script type="math/tex">d \geq 0 <span class="arithmatex"><span class="MathJax_Preview">，则取右侧像素</span><script type="math/tex">，则取右侧像素</script></span>(x_{i+1},y_{i,r})(x_{i+1},y_{i,r})</script></span>，则再下一个像素<span class="arithmatex"><span class="MathJax_Preview">d=F(x_{i+2},y_{i,r}+0.5)=a*(x_i+2)+b*(y_{i,r}+0.5)+c=d+a</span><script type="math/tex">d=F(x_{i+2},y_{i,r}+0.5)=a*(x_i+2)+b*(y_{i,r}+0.5)+c=d+a</script></span></p>
<p>此时d的增量为a</p>
</li>
<li>
<p>若<span class="arithmatex"><span class="MathJax_Preview">d&lt;0</span><script type="math/tex">d<0</script></span>，则取右上侧的像素<span class="arithmatex"><span class="MathJax_Preview">(x_{i+1},y_{i,r}+1)</span><script type="math/tex">(x_{i+1},y_{i,r}+1)</script></span>，则再下一个像素</p>
<p><span class="arithmatex"><span class="MathJax_Preview">d=F(x_{i+2},y_{i,r}+1.5)=a*(x_i+2)+b*(y_{i,r}+1.5)+c=d+a+b</span><script type="math/tex">d=F(x_{i+2},y_{i,r}+1.5)=a*(x_i+2)+b*(y_{i,r}+1.5)+c=d+a+b</script></span></p>
<p>此时d的增量为a+b</p>
</li>
<li>
<p>d的初始值：<span class="arithmatex"><span class="MathJax_Preview">d_0=F(x_0+1, y_0+0.5)=F(x_0, y_0)+a+0.5*b</span><script type="math/tex">d_0=F(x_0+1, y_0+0.5)=F(x_0, y_0)+a+0.5*b</script></span>，因(x0, y0)在直线上，F(x0, y0)=0, 所以，<span class="arithmatex"><span class="MathJax_Preview">d_0 = a + 0.5*b</span><script type="math/tex">d_0 = a + 0.5*b</script></span></p>
</li>
<li>
<p>增量d的递推公式</p>
</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211207182412.png" alt="image-20211207182411257" style="zoom:50%;" /></p>
<ol>
<li>注意斜率大于1和负数的情况。</li>
</ol>
</li>
</ol>
</li>
</ol>
</li>
<li>
<p>扫描转换圆弧</p>
</li>
<li>
<p>平移圆心到原点，扫描转换后再平移到原位置</p>
</li>
<li>
<p>圆的八对称性：由八分之一圆弧上的点可计算其它各分段弧上的点，只需要扫描转换八分之一圆弧即可</p>
</li>
<li>
<p>主要方法：方程法、中点算法和逼近法</p>
</li>
<li>
<p>主要算法</p>
<ol>
<li>
<p>方程法</p>
<ol>
<li>离散点：<span class="arithmatex"><span class="MathJax_Preview">x^2+y^2=R^2</span><script type="math/tex">x^2+y^2=R^2</script></span>，则<span class="arithmatex"><span class="MathJax_Preview">x_i,y_i=\sqrt{R^2-x_i^2}</span><script type="math/tex">x_i,y_i=\sqrt{R^2-x_i^2}</script></span>取整得到<span class="arithmatex"><span class="MathJax_Preview">(x_i,y_i)</span><script type="math/tex">(x_i,y_i)</script></span></li>
<li>离散角度：利用参数方程：<span class="arithmatex"><span class="MathJax_Preview">x=R*cos \theta.y=R*sin\theta</span><script type="math/tex">x=R*cos \theta.y=R*sin\theta</script></span></li>
</ol>
</li>
<li>
<p>中点算法</p>
<ol>
<li>
<p>圆弧的正负划分性</p>
<p>圆弧外的点：<span class="arithmatex"><span class="MathJax_Preview">F(x,y)&gt;0</span><script type="math/tex">F(x,y)>0</script></span>；圆弧上的点：<span class="arithmatex"><span class="MathJax_Preview">F(x,y)=0</span><script type="math/tex">F(x,y)=0</script></span>；圆弧内的点：<span class="arithmatex"><span class="MathJax_Preview">F(x,y)&lt;0</span><script type="math/tex">F(x,y)<0</script></span></p>
</li>
<li>
<p>八分圆的选择</p>
<p>第一象限的八分之一圆弧中x 的变化大于 y 的变化，即圆弧上的切矢量斜率在0 ... -1间。</p>
<p>因此可以使 x 从0 增加到 R/(21/2)，计算 y 的值。</p>
</li>
<li>
<p>確定下一像素点</p>
<p>点<span class="arithmatex"><span class="MathJax_Preview">p(x_i, y_{i,r})</span><script type="math/tex">p(x_i, y_{i,r})</script></span>下一点所取可能点间线段的中点，<span class="arithmatex"><span class="MathJax_Preview">M = (x_{i+1}, y_{i,r} - 0.5)</span><script type="math/tex">M = (x_{i+1}, y_{i,r} - 0.5)</script></span></p>
<p>当F(M)≤0时，M在圆内，说明E距离圆弧更近，取<span class="arithmatex"><span class="MathJax_Preview">(x_{i+1},y_{i,r})</span><script type="math/tex">(x_{i+1},y_{i,r})</script></span></p>
<p>当F(M)＞0时， M在圆外， 取<span class="arithmatex"><span class="MathJax_Preview">(x_{i+1},y_{i,r}-1)</span><script type="math/tex">(x_{i+1},y_{i,r}-1)</script></span></p>
</li>
<li>
<p>构造判别式</p>
<p><span class="arithmatex"><span class="MathJax_Preview">d_i = F(M) = F(x_i+1, y_{i,r}-0.5) = (x_i+1)^2+(y_i-0.5)^2-R^2</span><script type="math/tex">d_i = F(M) = F(x_i+1, y_{i,r}-0.5) = (x_i+1)^2+(y_i-0.5)^2-R^2</script></span></p>
<p>若<span class="arithmatex"><span class="MathJax_Preview">d \leq 0</span><script type="math/tex">d \leq 0</script></span>，则再下一个像素点判定式<span class="arithmatex"><span class="MathJax_Preview">d_{i+1}=F(x_i+2,y_{i,r}-0.5)=d+2x_i+3</span><script type="math/tex">d_{i+1}=F(x_i+2,y_{i,r}-0.5)=d+2x_i+3</script></span></p>
<p>若<span class="arithmatex"><span class="MathJax_Preview">d&gt;0</span><script type="math/tex">d>0</script></span>，则再下一个像素点判定式<span class="arithmatex"><span class="MathJax_Preview">d_{i+1}=F(x_i+2,y_{i,r}-1.5)=d+(2x_i+3)+(-2y_{i,r}+2)</span><script type="math/tex">d_{i+1}=F(x_i+2,y_{i,r}-1.5)=d+(2x_i+3)+(-2y_{i,r}+2)</script></span></p>
</li>
<li>
<p>d的初始值</p>
<p><span class="arithmatex"><span class="MathJax_Preview">d_0=F(1,R-0.5)=1.25-R</span><script type="math/tex">d_0=F(1,R-0.5)=1.25-R</script></span></p>
</li>
<li>
<p>递推公式</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211207230453.png" alt="image-20211207230451615" style="zoom: 67%;" /></p>
</li>
<li>
<p>消除乘法运算</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211207231025.png" alt="image-20211207231025042" style="zoom:67%;" /></p>
</li>
</ol>
</li>
<li>
<p>逼近法</p>
<ol>
<li>两种方法：正内接多边形迫近法、等面积正多边形迫近法</li>
<li>
<p>特点：多边形边数足够多时接近圆、误差控制边数：边越多精度越高，但计算开销大、多边形的边可用直线段的中点算法来生成</p>
</li>
<li>
<p>正内接多边形迫近法</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211207235645.png" alt="image-20211207235645358" style="zoom:50%;" /></p>
<p>​   <img src="https://pic.tim-wcx.ltd//img/20211207235732.png" alt="image-20211207235732664" style="zoom:50%;" /></p>
</li>
</ol>
</li>
</ol>
</li>
</ol>
<p><strong>填充图元生成</strong></p>
<ol>
<li>两种方法扫描转换: </li>
</ol>
<p>参数－&gt;点阵、填充（Filling） : 点阵－&gt;点阵</p>
<ol>
<li>
<p>共享边界：左闭右开，下闭上开</p>
</li>
<li>
<p>扫描转换多边形</p>
</li>
<li>
<p>两种方法：逐点判断法；扫描线算法；</p>
</li>
<li>
<p>多边形分类</p>
<p>凸多边形(convex)：内角小于180度</p>
<p>凹多边形(concave)：存在内角大于180度</p>
<p>只考虑：简单多边形，即多边形边不自相交</p>
</li>
<li>
<p>逐点判断发，即为判断每个点和多边形的内外关系--射线法</p>
<ol>
<li>
<p>步骤</p>
<p>（1）从待判别点 v 发出射线（任意方向，一般水平方向）</p>
<p>（2）求与多边形交点个数 k</p>
<p>（3）k 的奇偶性决定了点与多边形的内外关系 偶数：外 奇数：内</p>
</li>
<li>
<p>奇异情况</p>
<p>射线在边上：无数个点 ---判断射线是否与边同线</p>
<p>交点为顶点：异侧：1个、同侧：0或2个</p>
</li>
</ol>
</li>
<li>
<p>扫描线算法</p>
<ol>
<li>
<p>目标：利用相邻像素之间的连贯性，提高算法效率</p>
</li>
<li>
<p>处理对象：简单多边形 非自交多边形 （边与边之间除了顶点外无其它交点）</p>
</li>
<li>
<p>步骤（对于每一条扫描线）</p>
<ol>
<li>计算扫描线与边的交点</li>
<li>交点按x坐标从小到大排序</li>
<li>交点两两配对，填充区间</li>
</ol>
</li>
<li>
<p>基本方法</p>
<ol>
<li>
<p>将整个绘图窗口内扫描多边形的问题分解为一条条扫描线计算与多边形的相交区间，只要完成每条扫描线的生成就实现了多边形的扫描转换</p>
</li>
<li>
<p>一条扫描线与多边形的边有偶数个交点，每2个点形成一区间，区间内的像素位于多边形内</p>
</li>
</ol>
</li>
<li>
<p>连贯性(Coherence)</p>
<ol>
<li>
<p>边的连贯性(Edge Coherence)—优化交点计算</p>
<p>某条边与当前扫描线相交，也可能与下一条扫描线相交</p>
</li>
<li>
<p>扫描线的连贯性(Scan-line Coherence) )—优化交点排序</p>
<p>当前扫描线与各边的交点顺序与 下一条扫描线与各边的交点顺序可能相同或类似</p>
</li>
<li>
<p>区间的连贯性(Span Coherence)</p>
<p>同一区间上的像素取同一颜色属性</p>
</li>
</ol>
</li>
<li>
<p>交点</p>
<ol>
<li>第一类交点：位于同一条边上的后继交点，由扫描线y＝e与多边形的交点递推计算扫描线 y＝e＋1的交点，x’＝x＋1/m</li>
<li>第二类交点：边与扫描线的第一个交点，边的下端点即为交点。</li>
</ol>
</li>
<li>
<p>交点取整规则</p>
<ol>
<li>
<p>使生成的像素全部位于多边形之内，且满足共享边界原则。</p>
<p>（1）交点坐标不能采用“四舍五入”原则，否则会导致部分像素位于多边形之外</p>
<p>（2）共享边界原则：左闭右开，下闭上开</p>
</li>
<li>
<p>交点横坐标x为小数，即交点落于扫描线上两个相邻像素之间</p>
<p>（a）交点位于左边上，向右取整，(int)x + 1</p>
<p>（b）交点位于右边上，向左取整，(int)x</p>
</li>
<li>
<p>交点横坐标x为整数，落在右、上边界的像素不予填充。落在左、下边界的像素需要填充。</p>
</li>
<li>
<p>交点是顶点，扫描线与多边形的顶点相交时，采用上开下闭及右开左闭取交点，保证交点正确配对。</p>
<p>检查两相邻边在扫描线的哪一侧。只要检查相交的两条边的另外两个端点的Y值，两个端点Y中值大于交点Y值的个数是0，1，2，来决定取0，1，2个交点。</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211208164405.png" alt="image-20211208154212784" style="zoom: 67%;" /></p>
<p>分别对应交点个数为1个、1个、2个和0个。</p>
</li>
<li>
<p>水平边，不参与计算交点</p>
</li>
<li>
<p>排序，利用扫描线连贯性，采用插入排序。</p>
</li>
<li>
<p>交点两两配对与区间绘制，区间连续性，连续绘制区间上的像素。</p>
</li>
</ol>
</li>
<li>
<p>算法实现</p>
<ol>
<li>
<p>边的分类表ET （Edge Table）（又称新边表NET）</p>
<p>按照边的下端点  y  坐标，对非水平边进行分类的链表</p>
<p>下端点 y 坐标值等于i 的边属于第i类，同类中有多条边时按x从小到大排序（x也一样时按边上端点的x值）</p>
<p>作用：避免盲目求交；计算第二类交点坐标</p>
<p><img alt="image-20211208155018492" src="https://pic.tim-wcx.ltd//img/20211208155018.png" /></p>
<p>ET的结点信息：</p>
<p>ymax: 边的上端点的 y 坐标值</p>
<p>x：边的下端点的 x 坐标</p>
<p>deltax：边的斜率的倒数</p>
<p>nextEdge: 下一条边的指针</p>
<p>当扫描线 y = e + 1 == ymax，说明下一条扫描线与此边不相交。</p>
</li>
<li>
<p>活性边表AEL(Active Edge List)</p>
<p>存放活性边的顺序链表，且按交点 x 的值从小到大排序</p>
<p>活性边：与当前扫描线相交的边</p>
<p>边结构定义：与ET表中结点结构相同。</p>
<div class="language-c highlight"><pre><span></span><code><span id="__span-1-1"><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a><span class="k">typedef</span><span class="w"> </span><span class="k">struct</span><span class="w"> </span>
</span><span id="__span-1-2"><a id="__codelineno-1-2" name="__codelineno-1-2" href="#__codelineno-1-2"></a><span class="p">{</span>
</span><span id="__span-1-3"><a id="__codelineno-1-3" name="__codelineno-1-3" href="#__codelineno-1-3"></a><span class="w">    </span><span class="kt">int</span><span class="w"> </span><span class="n">ymax</span><span class="p">;</span>
</span><span id="__span-1-4"><a id="__codelineno-1-4" name="__codelineno-1-4" href="#__codelineno-1-4"></a><span class="w">     </span><span class="kt">float</span><span class="w"> </span><span class="n">x</span><span class="p">,</span><span class="w"> </span><span class="n">deltax</span><span class="p">;</span>
</span><span id="__span-1-5"><a id="__codelineno-1-5" name="__codelineno-1-5" href="#__codelineno-1-5"></a><span class="w">     </span><span class="n">Edge</span><span class="w"> </span><span class="o">*</span><span class="n">nextEdge</span><span class="p">;</span>
</span><span id="__span-1-6"><a id="__codelineno-1-6" name="__codelineno-1-6" href="#__codelineno-1-6"></a><span class="w"> </span><span class="p">}</span><span class="n">Edge</span><span class="p">;</span><span class="w"> </span>
</span></code></pre></div>
<p>AEL 的结点信息：</p>
<p>ymax: 所交边的最大 y 值</p>
<p>x：当前扫描线与边的交点的x坐标</p>
<p>deltax：边的斜率的倒数</p>
<p>nextEdge: 下一条边的指针</p>
<p>作用：存储与当前扫描线的交点，同时快速计算下一条扫描线与多边形相交的点，且可判断边是否与下一条扫描线相交</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211208155609.png" alt="image-20211208155609510" style="zoom:67%;" /></p>
</li>
</ol>
<p><img alt="image-20211208155836440" src="https://pic.tim-wcx.ltd//img/20211208155836.png" /></p>
</li>
</ol>
</li>
</ol>
<p><strong>种子填充算法</strong></p>
<ol>
<li>
<p>区域：点阵表示的图形，像素集合</p>
</li>
<li>
<p>表示方法：内点表示、边界表示</p>
<ol>
<li>
<p>内点表示</p>
<p>枚举出区域内部的所有像素、内部的所有像素为同一个颜色、边界像素与内部像素的颜色不同</p>
</li>
<li>
<p>边界表示</p>
<p>枚举出边界上所有的像素、边界上的所有像素为同一颜色、内部像素与边界像素的颜色不同</p>
</li>
<li>
<p>区域填充算法要求区域是连通的。</p>
</li>
</ol>
</li>
<li>
<p>连通性</p>
</li>
</ol>
<p>（1）4连通区域：区域中任意满足相似条件两点（像素）可通过上下左右四个方向互相到达</p>
<p>（2）8连通区域：区域中任意满足相似条件两点（像素）可通过上下左右和对角线八 个方向互相到达</p>
<ol>
<li>
<p>4连通区域，边界只要8连通即可，8连通区域，边界必须是4连通。</p>
</li>
<li>
<p>算法实现：</p>
</li>
</ol>
<p>（1）内点表示的4连通区域
   种子s(x,y)，原色oldColor，新颜色newColor</p>
<p>方法：先判断s(x, y)的颜色，若其值不等于oldColor，说明该像素位于区域外或已设置为填充色newColor 算法结束；</p>
<p>否则，置像素颜色为newColor，再对其相邻的上下左右四个像素分别作为种子作上述递归处理。</p>
<ol>
<li>多边形扫描转换与区域填充方法比较</li>
<li>
<p>基本思想不同</p>
<p>前者：顶点表示转换成点阵表示</p>
<p>后者：只改变区域内填充颜色，没有改变表示方法</p>
</li>
<li>
<p>对边界的要求不同</p>
<p>前者：扫描线与多边形边界交点个数为偶数</p>
<p>后者：区域封闭，防止递归填充跨界</p>
</li>
<li>
<p>基本的条件不同</p>
<p>前者：从边界顶点信息出发</p>
<p>后者：从区域内种子点出发</p>
</li>
<li>
<p>区域图像填充</p>
</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211208162030.png" alt="image-20211208162030115" style="zoom: 80%;" /></p>
<p><strong>字符的生成</strong></p>
<ol>
<li>点阵字体</li>
</ol>
<p>存储：（压缩与非压缩）</p>
<p>显示：根据编码检索点阵数据，接着写帧缓存</p>
<ol>
<li>矢量字体</li>
</ol>
<p>表示：笔画用曲线（参数）表示</p>
<p>扫描转换：参数到点阵</p>
<p>显示：1、由编码检索；2、扫描转换；3、写帧缓存</p>
<p>存储：空间少</p>
<p><strong>OpenGL相关函数</strong></p>
<div class="language-c highlight"><pre><span></span><code><span id="__span-2-1"><a id="__codelineno-2-1" name="__codelineno-2-1" href="#__codelineno-2-1"></a><span class="c1">//图元绘制</span>
</span><span id="__span-2-2"><a id="__codelineno-2-2" name="__codelineno-2-2" href="#__codelineno-2-2"></a><span class="n">glBegin</span><span class="p">(</span><span class="n">type</span><span class="p">);</span>
</span><span id="__span-2-3"><a id="__codelineno-2-3" name="__codelineno-2-3" href="#__codelineno-2-3"></a><span class="w">    </span><span class="n">glVertex</span><span class="o">*</span><span class="p">();</span><span class="w"> </span><span class="c1">//指定顶点坐标1</span>
</span><span id="__span-2-4"><a id="__codelineno-2-4" name="__codelineno-2-4" href="#__codelineno-2-4"></a><span class="w">    </span><span class="n">glVertex</span><span class="o">*</span><span class="p">();</span><span class="w"> </span><span class="c1">//指定顶点坐标2</span>
</span><span id="__span-2-5"><a id="__codelineno-2-5" name="__codelineno-2-5" href="#__codelineno-2-5"></a><span class="n">glEnd</span><span class="p">()</span><span class="err">；</span>
</span><span id="__span-2-6"><a id="__codelineno-2-6" name="__codelineno-2-6" href="#__codelineno-2-6"></a>
</span><span id="__span-2-7"><a id="__codelineno-2-7" name="__codelineno-2-7" href="#__codelineno-2-7"></a><span class="c1">//点的属性</span>
</span><span id="__span-2-8"><a id="__codelineno-2-8" name="__codelineno-2-8" href="#__codelineno-2-8"></a><span class="n">glEnable</span><span class="p">(</span><span class="n">GL_LINE_STIPPLE</span><span class="p">);</span><span class="w">  </span>
</span><span id="__span-2-9"><a id="__codelineno-2-9" name="__codelineno-2-9" href="#__codelineno-2-9"></a><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="n">glColor</span><span class="p">(</span><span class="mi">3</span><span class="o">|</span><span class="mi">4</span><span class="p">)(</span><span class="n">b</span><span class="o">|</span><span class="n">d</span><span class="o">|</span><span class="n">f</span><span class="o">|</span><span class="n">i</span><span class="o">|</span><span class="n">s</span><span class="o">|</span><span class="n">ub</span><span class="o">|</span><span class="n">ui</span><span class="o">|</span><span class="n">us</span><span class="p">)(</span><span class="n">TYPE</span><span class="w"> </span><span class="n">r</span><span class="p">,</span><span class="n">TYPE</span><span class="w"> </span><span class="n">g</span><span class="p">,</span><span class="n">TYPE</span><span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="p">)</span>
</span><span id="__span-2-10"><a id="__codelineno-2-10" name="__codelineno-2-10" href="#__codelineno-2-10"></a><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="w"> </span><span class="n">glColor</span><span class="p">(</span><span class="mi">3</span><span class="o">|</span><span class="mi">4</span><span class="p">)(</span><span class="n">b</span><span class="o">|</span><span class="n">d</span><span class="o">|</span><span class="n">f</span><span class="o">|</span><span class="n">i</span><span class="o">|</span><span class="n">s</span><span class="o">|</span><span class="n">ub</span><span class="o">|</span><span class="n">ui</span><span class="o">|</span><span class="n">us</span><span class="p">)</span><span class="n">v</span><span class="p">(</span><span class="n">TYPE</span><span class="w"> </span><span class="o">*</span><span class="n">rgb</span><span class="w"> </span><span class="p">)</span>
</span><span id="__span-2-11"><a id="__codelineno-2-11" name="__codelineno-2-11" href="#__codelineno-2-11"></a><span class="n">glPointSize</span><span class="err">（</span><span class="n">GLfloat</span><span class="w">  </span><span class="n">size</span><span class="p">)</span><span class="w"> </span><span class="c1">//点大小</span>
</span><span id="__span-2-12"><a id="__codelineno-2-12" name="__codelineno-2-12" href="#__codelineno-2-12"></a>
</span><span id="__span-2-13"><a id="__codelineno-2-13" name="__codelineno-2-13" href="#__codelineno-2-13"></a><span class="c1">//画线</span>
</span><span id="__span-2-14"><a id="__codelineno-2-14" name="__codelineno-2-14" href="#__codelineno-2-14"></a><span class="n">glBegin中的参数为</span><span class="err">：</span><span class="n">GL_LINES</span><span class="err">、</span><span class="n">GL_LINE_STRIP</span><span class="err">、</span><span class="n">GL_LINE_LOOP</span>
</span><span id="__span-2-15"><a id="__codelineno-2-15" name="__codelineno-2-15" href="#__codelineno-2-15"></a><span class="n">GL_LINES</span><span class="err">：</span><span class="n">一组直线段</span><span class="err">；</span><span class="w"> </span><span class="n">GL_LINE_STRIP</span><span class="err">：</span><span class="n">折线</span><span class="w"> </span><span class="n">GL_LINE_LOOP</span><span class="err">：</span><span class="n">封闭折线</span>
</span><span id="__span-2-16"><a id="__codelineno-2-16" name="__codelineno-2-16" href="#__codelineno-2-16"></a>
</span><span id="__span-2-17"><a id="__codelineno-2-17" name="__codelineno-2-17" href="#__codelineno-2-17"></a><span class="c1">//线的属性</span>
</span><span id="__span-2-18"><a id="__codelineno-2-18" name="__codelineno-2-18" href="#__codelineno-2-18"></a><span class="n">glLineWidth</span><span class="err">（</span><span class="n">GLfloat</span><span class="w"> </span><span class="n">width</span><span class="p">)</span><span class="w"> </span><span class="c1">//宽度</span>
</span><span id="__span-2-19"><a id="__codelineno-2-19" name="__codelineno-2-19" href="#__codelineno-2-19"></a><span class="n">glLineStipple</span><span class="p">(</span><span class="n">GLint</span><span class="w"> </span><span class="n">factor</span><span class="p">,</span><span class="w"> </span><span class="n">GLushort</span><span class="w"> </span><span class="n">pattern</span><span class="p">);</span><span class="w"> </span><span class="c1">//线形</span>
</span><span id="__span-2-20"><a id="__codelineno-2-20" name="__codelineno-2-20" href="#__codelineno-2-20"></a><span class="n">glEnable</span><span class="p">(</span><span class="n">GL_LINE_STIPPLE</span><span class="p">);</span><span class="w"> </span><span class="c1">//使用前需要激活</span>
</span><span id="__span-2-21"><a id="__codelineno-2-21" name="__codelineno-2-21" href="#__codelineno-2-21"></a>
</span><span id="__span-2-22"><a id="__codelineno-2-22" name="__codelineno-2-22" href="#__codelineno-2-22"></a><span class="c1">//填充图元函数</span>
</span><span id="__span-2-23"><a id="__codelineno-2-23" name="__codelineno-2-23" href="#__codelineno-2-23"></a><span class="n">glRect</span><span class="p">[</span><span class="n">i</span><span class="o">|</span><span class="n">s</span><span class="o">|</span><span class="n">f</span><span class="o">|</span><span class="n">d</span><span class="p">]{</span><span class="n">v</span><span class="p">}()</span><span class="c1">//矩形函数</span>
</span><span id="__span-2-24"><a id="__codelineno-2-24" name="__codelineno-2-24" href="#__codelineno-2-24"></a><span class="n">glBegin</span><span class="p">()</span><span class="n">中的参数GL_POLYGON</span><span class="err">、</span><span class="n">GL_TRIANGLES</span><span class="err">、</span><span class="n">GL_TRIANGLE_STRIP</span><span class="err">、</span><span class="n">GL_TRIANGLE_FAN</span>
</span><span id="__span-2-25"><a id="__codelineno-2-25" name="__codelineno-2-25" href="#__codelineno-2-25"></a>
</span><span id="__span-2-26"><a id="__codelineno-2-26" name="__codelineno-2-26" href="#__codelineno-2-26"></a><span class="c1">//线框图与填充图</span>
</span><span id="__span-2-27"><a id="__codelineno-2-27" name="__codelineno-2-27" href="#__codelineno-2-27"></a><span class="n">glPloygonMode</span><span class="p">(</span><span class="n">face</span><span class="err">，</span><span class="n">displayMode</span><span class="p">)</span>
</span><span id="__span-2-28"><a id="__codelineno-2-28" name="__codelineno-2-28" href="#__codelineno-2-28"></a><span class="c1">//face：指定前后面。可选值：GL_FRONT、GL_BACK和GL_FRONT_AND_BACK【正反面一样处理】</span>
</span><span id="__span-2-29"><a id="__codelineno-2-29" name="__codelineno-2-29" href="#__codelineno-2-29"></a><span class="c1">//displayMode：GL_FILL（填充）和GL_LINE（线框）</span>
</span><span id="__span-2-30"><a id="__codelineno-2-30" name="__codelineno-2-30" href="#__codelineno-2-30"></a>
</span><span id="__span-2-31"><a id="__codelineno-2-31" name="__codelineno-2-31" href="#__codelineno-2-31"></a><span class="c1">//颜色插值模式</span>
</span><span id="__span-2-32"><a id="__codelineno-2-32" name="__codelineno-2-32" href="#__codelineno-2-32"></a><span class="n">函数</span><span class="err">：</span><span class="n">glShadeModel</span><span class="p">(</span><span class="n">mode</span><span class="p">)</span>
</span><span id="__span-2-33"><a id="__codelineno-2-33" name="__codelineno-2-33" href="#__codelineno-2-33"></a><span class="nl">Mode</span><span class="p">:</span><span class="w"> </span><span class="n">GL_FLAT和GL_SMOOTH</span>
</span></code></pre></div>
<p>图元绘制 图元类型</p>
<table>
<thead>
<tr>
<th><strong>类型</strong></th>
<th><strong>说明</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>GL_POINTS</strong></td>
<td><strong>单个顶点集</strong></td>
</tr>
<tr>
<td><strong>GL_LINES</strong></td>
<td><strong>多组双顶点线段</strong></td>
</tr>
<tr>
<td><strong>GL_POLYGON</strong></td>
<td><strong>单个简单填充凸多边形</strong></td>
</tr>
<tr>
<td><strong>GL_TRIANGLES</strong></td>
<td><strong>多组独立填充三角形</strong></td>
</tr>
<tr>
<td><strong>GL_QUADS</strong></td>
<td><strong>多组独立填充四边形</strong></td>
</tr>
<tr>
<td><strong>GL_LINE_STRIP</strong></td>
<td><strong>不闭合折线</strong></td>
</tr>
<tr>
<td><strong>GL_LINE_LOOP</strong></td>
<td><strong>闭合折线</strong></td>
</tr>
<tr>
<td><strong>GL_TRIANGLE_STRIP</strong></td>
<td><strong>线型连续填充三角形串</strong></td>
</tr>
<tr>
<td><strong>GL_TRIANGLE_FAN</strong></td>
<td><strong>扇形连续填充三角形串</strong></td>
</tr>
<tr>
<td><strong>GL_QUAD_STRIP</strong></td>
<td><strong>连续填充四边形串</strong></td>
</tr>
</tbody>
</table>
<h3 id="_5">第四章 几何变换<a class="headerlink" href="#_5" title="Permanent link">&para;</a></h3>
<p><strong>齐次坐标</strong></p>
<ol>
<li>定义</li>
</ol>
<p>定义：(x，y)点对应的齐次坐标定义为<span class="arithmatex"><span class="MathJax_Preview">(x_h,y_h,h),x_h=h*x,y_h=y*h,z_h=h</span><script type="math/tex">(x_h,y_h,h),x_h=h*x,y_h=y*h,z_h=h</script></span></p>
<p>标准其次坐标：<span class="arithmatex"><span class="MathJax_Preview">(x,y,1)</span><script type="math/tex">(x,y,1)</script></span></p>
<div class="codehilite"><pre><span></span><code>h＝0表示无穷远点
</code></pre></div>

<p><strong>二维变换</strong></p>
<ol>
<li>二维变换的矩阵表示</li>
</ol>
<p>平移变换</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211208220842.png" alt="image-20211208220841726" style="zoom:67%;" /></p>
<p>旋转变换</p>
<p>绕坐标原点（称为参照点，基准点）旋转角度θ （逆时针为正，顺时针为负）</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211208220917.png" alt="image-20211208220917015" style="zoom:67%;" /></p>
<p>放缩变换</p>
<p>参照点为坐标原点</p>
<p><img alt="image-20211208220935328" src="https://pic.tim-wcx.ltd//img/20211208220935.png" /></p>
<p>变换具有统一表示形式的优点
   1. 便于变换合成 连续变换时，可以先得到变换的矩阵
   2. 便于硬件实现 只需实现矩阵乘法</p>
<ol>
<li>
<p>变换的性质</p>
</li>
<li>
<p>平移和旋转变换具有可加性</p>
<p><img alt="image-20211208221103935" src="https://pic.tim-wcx.ltd//img/20211208221103.png" /></p>
</li>
<li>
<p>放缩变换具有可乘性</p>
<p><img alt="image-20211208221124482" src="https://pic.tim-wcx.ltd//img/20211208221124.png" /></p>
</li>
<li>
<p>变换合成</p>
</li>
<li>
<p>方法：连续变换时，先计算变换矩阵，再计算坐标</p>
</li>
<li>
<p>优点：提高了对图形依次计算多次变换的运算效率、提供计算复杂变换的方法</p>
</li>
<li>
<p>复合变换 矩阵乘法</p>
</li>
</ol>
<p>先作用的放在变换矩阵连乘式的右端，后作用的放在连乘式的左端</p>
<p><span class="arithmatex"><span class="MathJax_Preview">p‘=M_n*...*M_2*M_1</span><script type="math/tex">p‘=M_n*...*M_2*M_1</script></span></p>
<ol>
<li>对称变换</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211208222245.png" alt="image-20211208222245543" style="zoom:67%;" /></p>
<ol>
<li>
<p>仿射变换</p>
</li>
<li>
<p>二维线性变换的一般形式</p>
<p><img alt="image-20211208222819070" src="https://pic.tim-wcx.ltd//img/20211208222819.png" /></p>
</li>
<li>
<p>平移，旋转，放缩，对称和错切是特例</p>
</li>
<li>
<p>保持平行线间的平行关系</p>
</li>
</ol>
<p><strong>三维几何变换</strong></p>
<ol>
<li>三维齐次坐标</li>
</ol>
<p>(x, y, z)点对应的齐次坐标为<span class="arithmatex"><span class="MathJax_Preview">(x_h,y_h,z_h,h)</span><script type="math/tex">(x_h,y_h,z_h,h)</script></span>，标准齐次坐标<span class="arithmatex"><span class="MathJax_Preview">(x,y,z,1)</span><script type="math/tex">(x,y,z,1)</script></span></p>
<ol>
<li>
<p>右手坐标系  旋转方向，当拇指与坐标轴同向时，四指所指方向为绕该轴的正旋转方向。</p>
</li>
<li>
<p>平移变换 </p>
</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211208223811.png" alt="image-20211208223810648" style="zoom:67%;" /></p>
<ol>
<li>放缩变换</li>
</ol>
<p>参照点为坐标原点</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211208223851.png" alt="image-20211208223851039" style="zoom: 67%;" /></p>
<ol>
<li>旋转变换</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211208224145.png" alt="image-20211208224145147" style="zoom:80%;" />
   3. 绕Z轴</p>
<div class="codehilite"><pre><span></span><code>  &lt;img src=&quot;https://pic.tim-wcx.ltd//img/20211208224303.png&quot; alt=&quot;image-20211208224303864&quot; style=&quot;zoom:67%;&quot; /&gt;
</code></pre></div>

<ol>
<li>对称变换</li>
</ol>
<p>关于坐标平面 xy 的对称变换</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211208224351.png" alt="image-20211208224351083" style="zoom:80%;" /></p>
<ol>
<li>三维几何变换的一般形式</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211208224502.png" alt="image-20211208224502712" style="zoom:80%;" /></p>
<p>（1）前三行和前三列对应旋转和放缩变换</p>
<p>（2）第四列的前三个元素对应平移变换</p>
<p>（3）第四行前三个元素对应投影变换</p>
<p><strong>图形对象的几何变换</strong></p>
<ol>
<li>
<p>图形对象 点，线段，多边形，圆，字符</p>
</li>
<li>
<p>方法</p>
</li>
<li>
<p>先生成点集，再对其中的点进行变换 运算量大，变换前后存在点集不一致情况</p>
</li>
<li>
<p>对几何参数变换</p>
<p>基本图形：线段，两个端点；多边形，多个顶点；圆，圆心和半径（放缩变换要求 x 和 y 放缩倍数相同）</p>
<p>前提：图形对象的几何性质不随坐标变换而发生变化。这种性质称为仿射不变性。</p>
</li>
</ol>
<p><strong>OpenGL几何变换函数</strong></p>
<div class="language-text highlight"><pre><span></span><code><span id="__span-3-1"><a id="__codelineno-3-1" name="__codelineno-3-1" href="#__codelineno-3-1"></a>glTranslate{fd}(tx, ty, tz) //平移函数
</span><span id="__span-3-2"><a id="__codelineno-3-2" name="__codelineno-3-2" href="#__codelineno-3-2"></a>glRotate{fd}(theta, vx, vy, vz) //旋转函数
</span><span id="__span-3-3"><a id="__codelineno-3-3" name="__codelineno-3-3" href="#__codelineno-3-3"></a>glScale{fd}(sx, sy, sz) //放缩函数
</span><span id="__span-3-4"><a id="__codelineno-3-4" name="__codelineno-3-4" href="#__codelineno-3-4"></a>glLoadIdentity() //重置为单位矩阵
</span><span id="__span-3-5"><a id="__codelineno-3-5" name="__codelineno-3-5" href="#__codelineno-3-5"></a>glMatrixMode(GL_MODELVIEW) //模型观察矩阵
</span><span id="__span-3-6"><a id="__codelineno-3-6" name="__codelineno-3-6" href="#__codelineno-3-6"></a>glPushMatrix() //压栈
</span><span id="__span-3-7"><a id="__codelineno-3-7" name="__codelineno-3-7" href="#__codelineno-3-7"></a>glPopMatrix() //出栈
</span><span id="__span-3-8"><a id="__codelineno-3-8" name="__codelineno-3-8" href="#__codelineno-3-8"></a>glutInitDisplayMode (GLUT_SINGLE|GLUT_RGBA); //单缓冲
</span><span id="__span-3-9"><a id="__codelineno-3-9" name="__codelineno-3-9" href="#__codelineno-3-9"></a>glutInitDisplayMode (GLUT_DOUBLE|GLUT_RGBA);   //双缓冲
</span><span id="__span-3-10"><a id="__codelineno-3-10" name="__codelineno-3-10" href="#__codelineno-3-10"></a>glFinish();//强制之前的绘图函数执行，双缓冲可不调用
</span><span id="__span-3-11"><a id="__codelineno-3-11" name="__codelineno-3-11" href="#__codelineno-3-11"></a>glutSwapBuffers(); //双缓冲必须调用
</span></code></pre></div>
<p>注意：</p>
<p>(1)系统几何变换矩阵只有1个</p>
<p>(2)坐标采用列向量表示</p>
<p>(3)旋转角大小用度表示，不是弧度</p>
<p>(4)绘图时，用系统的几何变换矩阵与顶点坐标相乘得到坐标进行绘图</p>
<p>(5)<strong>只需要连续调用变换函数，先变换的函数后调用，最后绘制该图形。</strong></p>
<h3 id="_6">第五章 二维图形的显示<a class="headerlink" href="#_6" title="Permanent link">&para;</a></h3>
<p><strong>二维显示流水线</strong></p>
<ol>
<li>基本概念</li>
<li>
<p>裁剪窗口(Clipping Window) ：需要显示的场景区域</p>
<p>又称为世界窗口或观察窗口，简称窗口</p>
<p>在世界坐标系（又称用户坐标系）内定义</p>
</li>
<li>
<p>视口(Viewport)：指显示设备上用来显示图形的区域</p>
<p>又称视区，在设备（屏幕）坐标系内定义</p>
</li>
<li>
<p>裁剪(Clip)：从场景中确定位于窗口内的图形</p>
</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211208231044.png" alt="image-20211208231043411" style="zoom:67%;" /></p>
<ol>
<li>裁剪窗口和视区的关系</li>
<li>
<p>改变视口位置可以在输出设备的不同位置上观察物体</p>
</li>
<li>
<p>使用多个视口可以在屏幕不同的位置观察场景的不同部分</p>
</li>
<li>
<p>改变窗口的尺寸达到改变视口内显示对象的多少</p>
</li>
<li>
<p>改变视口（或窗口）的尺寸实现图形对象放缩</p>
<p><img alt="image-20211208231326960" src="https://pic.tim-wcx.ltd//img/20211208231327.png" /></p>
</li>
<li>
<p>二维显示变换</p>
</li>
</ol>
<p>二维图形的世界坐标系到设备坐标系的映射</p>
<p>又称为窗口到视区的变换或窗口变换</p>
<ol>
<li>二维图形的显示流水线</li>
</ol>
<p><img alt="image-20211208231610251" src="https://pic.tim-wcx.ltd//img/20211208231610.png" /></p>
<p><strong>窗口到视区的变换</strong></p>
<ol>
<li>步骤</li>
<li>在世界坐标系中，平移窗口使(xmin,  ymin)至坐标原点，变换为T (－xmin,  －ymin)</li>
<li>放缩使窗口的大小与视区相等，变换为S(Eu/Ex, Ev/Ey)</li>
<li>在设备坐标系中，平移使窗口与视区重合，变换为T (umin, vmin)</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211208231827.png" alt="image-20211208231827345" style="zoom:67%;" /></p>
<ol>
<li>OpenGL视区函数</li>
</ol>
<p>glViewport(xvmin,yvmin,vpwidth,vpheight);</p>
<ol>
<li>GLU裁剪窗口函数</li>
</ol>
<p>gluOrtho2D(left,right,bottom,top);</p>
<p>功能：将图形数据映射到屏幕的正交投影，在二维图形中可以看做设定x，y最大最小值。</p>
<p>默认大小为（－1，1，－1，1）</p>
<p><strong>裁剪</strong></p>
<ol>
<li>定义</li>
</ol>
<p>判断图形元素是否落在裁剪窗口之内并找出其位于内部的部分。</p>
<ol>
<li>裁剪的次序</li>
</ol>
<p>（1）扫描转换后裁剪：设备坐标系，点阵表示图形</p>
<p>算法简单（判断像素是否落在视区中），所有图形都要先扫描转换，速度慢。</p>
<p>（2）裁剪后扫描转换：世界坐标系，参数表示图形</p>
<p>最常用，节约计算时间（先对参数表示的图形裁剪），算法复杂</p>
<ol>
<li>假定条件</li>
</ol>
<p>矩形裁剪窗口：[xmin, ymin]－[xmax, ymax]</p>
<p>被裁剪对象：线段、多边形</p>
<p><strong>直线段裁剪</strong></p>
<ol>
<li>待裁剪线段和窗口的关系</li>
</ol>
<p>(1) 完全可见：端点位于窗口内AB</p>
<p>(2) 显然不可见 ：端点位于同边界外侧EF</p>
<p>(3) 线段至少有一端点在窗口之外，但非显然不可见</p>
<ol>
<li>
<p>直线段直接求交算法</p>
</li>
<li>
<p>端点与窗口位置关系</p>
<p>(1) 都在窗口内（完全可见）</p>
<p>(2) 1个在窗口内，另一个在外 (有1个交点)</p>
<p>(3) 2个都不在窗口内</p>
<p>显然不可见？、可能相交，2个交点连接线段、可能不相交</p>
</li>
<li>
<p>计算交点方法</p>
<p>线段与窗口的边求交点，直线与窗口边都写成参数形式，求参数值</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211209185350.png" alt="image-20211209185348465" style="zoom:80%;" /></p>
</li>
<li>
<p>算法流程</p>
</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211209185951.png" alt="image-20211209185951098" style="zoom:67%;" /></p>
<ol>
<li>
<p>特点</p>
<p>方法直接，易懂。不能快速判断显然不可见的线段。</p>
</li>
<li>
<p>编码算法</p>
</li>
<li>
<p>算法步骤</p>
<p>第一步 判别线段两端点是否都落在窗口内，如果是，则线段完全可见；否则进入第二步；</p>
<p>第二步 判别线段是否为显然不可见，如果是，则裁剪结束；否则进行第三步  ；</p>
<p>第三步 求线段与窗口边延长线的交点，这个交点将线段分为两段，其中一段显然不可见，丢弃。</p>
<p>对余下的另一段重新进行第一步，</p>
<p>第二步，第三步处理， 直至结束。</p>
</li>
<li>
<p>区域编码</p>
<p>由窗口四条边所在直线把二维平面分成9个子区域，每个子区域赋予一个四位编码，<span class="arithmatex"><span class="MathJax_Preview">C_tC_bC_rC_l</span><script type="math/tex">C_tC_bC_rC_l</script></span>，上下右左。</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211209191145.png" alt="image-20211209191145865" style="zoom:80%;" /></p>
</li>
<li>
<p>根据顶点编码判断线段与多边形的关系</p>
<p>当两个端点的编码全为0时，线段完全可见。</p>
<p>当线段的两个端点的编码的逻辑“与”非零时 ，线段为显然不可见的。</p>
</li>
<li>
<p>（1）求交前先测试与窗口哪条边所在直线有交？</p>
<p>规则：判断端点编码中各位的值<span class="arithmatex"><span class="MathJax_Preview">C_tC_bC_rC_l</span><script type="math/tex">C_tC_bC_rC_l</script></span>，分别对应：上、下、右和左边</p>
<p>端点码值位值不同时，说明线段与对应窗口边相交</p>
<p>次序：上、下、右和左边</p>
<p>（2）以交点为界，丢弃外侧线段，</p>
<p>以交点为新端点判断另一线段，重复算法的步骤</p>
</li>
<li>
<p>特点</p>
<p>(1) 对完全可见和显然不可见线段的快速判别</p>
<p>(2) 二种场合效率高</p>
<p>​ 大裁剪窗口以及裁剪窗口特别小 (如, 光标拾取图形时，光标看作小的裁剪窗口）</p>
<p>(3) 裁剪窗口的拓展性</p>
<p>​ 可以延伸为凸多边形，但随着边数的增加，编码变复杂</p>
</li>
<li>
<p>Liang-Barsky裁剪算法</p>
</li>
<li>
<p>基本思想</p>
<p>将二维裁剪化为一维裁剪，向X（或Y）方向投影以决定可见线段</p>
</li>
<li>
<p>前提</p>
<p>平行于X或Y轴的线段较容易，这里不作考虑</p>
<p>假设P0P1或其延长线分别与窗口左、下、右和上边（或其延长线）交于L，B，R，T</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211209192142.png" alt="image-20211209192141468" style="zoom: 80%;" /></p>
</li>
<li>
<p>方法</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211209194611.png" alt="image-20211209194610754" style="zoom: 67%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211209194647.png" alt="image-20211209194646928" style="zoom: 67%;" /></p>
<p>​     （4）代入直线方程得到交点坐标。</p>
</li>
<li>
<p>L-B算法的改进，减少求交点的次数</p>
<ol>
<li>
<p>LL = max(xmin, min(x0, x1)) ，RR = min(xmax, max(x0, x1))</p>
</li>
<li>
<p><img src="https://pic.tim-wcx.ltd//img/20211209203033.png" alt="image-20211209203033630" style="zoom:80%;" /></p>
</li>
<li>
<p>算法</p>
<p>(1)先测试 LL≤RR？不成立，不存在可见线段，退出；否则，执行（2）</p>
<p>(2)线段P1P2的斜率K&gt;0? 不是执行（3），否则执行。</p>
<p>计算xT, 测试 LL ≤xT？若成立，计算xB，测试 xB ≤RR？若成立，有可见线段： xα = max(LL，xB); xβ = min(RR，xT)</p>
<p>(3)K&lt;0:计算xB,测试 LL ≤xB？若成立，计算xT，测试 xT ≤R？若成立，有可见线段： xα = max(LL ,xT); xβ = min(RR, xB)</p>
</li>
<li>
<p>特点
     （1）二维转化为一维（2）按需求交点，提高效率</p>
</li>
</ol>
</li>
</ol>
<p><strong>多边形裁剪</strong></p>
<ol>
<li>
<p>S-H（逐边）裁剪算法基本思想</p>
</li>
<li>
<p>输入输出：顶点序列<span class="arithmatex"><span class="MathJax_Preview">V_0V_1V_2V_3V_4 ….</span><script type="math/tex">V_0V_1V_2V_3V_4 ….</script></span></p>
</li>
<li>
<p>定义：</p>
<p>裁剪线：窗口边以及其延长线</p>
<p>内侧空间与外侧空间：包含裁剪窗口的半空间为内侧空间，否则为外侧空间。</p>
</li>
<li>
<p>多边形与窗口裁剪线的裁剪</p>
<p>化解为多边形每条边与裁剪线裁剪。</p>
<p>边与裁剪线的裁剪方法：依据多边形的边SP（S是起点）与半空间（内外侧）的关系</p>
<p>情况1：同在内侧，裁剪后输出P</p>
<p>情况2：S 在内侧，P 在外侧，裁剪后输出交点 i</p>
<p>情况3：同在外侧，裁剪后不输出</p>
<p>情况4：S 在外侧， P 在内侧，裁剪后输出交点 i 和 P</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211209204411.png" alt="image-20211209204410959" style="zoom: 80%;" /></p>
</li>
<li>
<p>算法</p>
<p>将顶点序列P1P2…Pn作为输入</p>
<p>依次对窗口的每条裁剪线作下列处理</p>
<p>输入顶点序列</p>
<p>依次顶点序列中相邻顶点构成的边PiPi+1进行裁剪处理</p>
<p>输出顶点序列（下条裁剪线的输入）</p>
</li>
<li>
<p>SH扫描顺序：左上右下</p>
</li>
<li>
<p>特点</p>
<ol>
<li>
<p>裁剪算法采用流水线方式，算法简单</p>
</li>
<li>
<p>推广到任意凸多边形裁剪窗口</p>
<p>原因是：凸多边形的边能将平面空间分成2部分，其中一部分含裁剪窗口</p>
</li>
</ol>
</li>
<li>
<p>Weiler-Athenton算法</p>
</li>
<li>
<p>适用于裁剪窗口为任意多边形（凸、凹、带内环）的情况</p>
</li>
<li>
<p>内裁剪特点</p>
<p>裁剪结果区域的边界由A的部分边界和B的部分边界两部分构成，并且在交点处边界发生交替，即由A的边界转至B的边界，或由B的边界转至A的边界。</p>
</li>
<li>
<p>交点</p>
<p>出点：主多边形边界由此离开裁剪多边形区域。</p>
<p>进点：主多边形边界由此进入裁剪多边形内。</p>
</li>
</ol>
<p><strong>字符裁剪</strong></p>
<ol>
<li>基于字符串</li>
</ol>
<p>整个字符串完全落在窗口之内时显示，否则不显示。</p>
<p>字符串的矩形包围盒测试。</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211209205246.png" alt="image-20211209205245978" style="zoom:80%;" /></p>
<ol>
<li>基于字符</li>
</ol>
<p>一个字符完全落在窗口之内时显示，否则不显示。</p>
<p>字符的矩形包围盒测试。</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211209205327.png" alt="image-20211209205327287" style="zoom:80%;" /></p>
<ol>
<li>基于构成字符的最小元素 </li>
</ol>
<p>点阵字符：点裁剪</p>
<p>矢量字符：线裁剪</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211209205331.png" alt="image-20211209205331355" style="zoom: 67%;" /></p>
<h3 id="_7">第六章 三维图形的显示<a class="headerlink" href="#_7" title="Permanent link">&para;</a></h3>
<p><strong>三维图像简介</strong></p>
<ol>
<li>三维成像基本步骤</li>
</ol>
<p>（1）选定投影类型 —— 平行、透视</p>
<p>（2）设置投影参数—— 拍摄方向、距离等</p>
<p>（3）三维裁剪 ——取景</p>
<p>（4）投影和显示——成像</p>
<ol>
<li>简单的三维图形显示流程图</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211210160450.png" alt="image-20211210160449286" style="zoom:80%;" /></p>
<ol>
<li>平面几何投影分类</li>
<li>平行投影(parallel projection)投影中心与投影平面之间的距离为无限</li>
<li>透视投影(perspective projection)投影中心与投影平面之间的距离为有限</li>
</ol>
<p><img alt="image-20211210160608239" src="https://pic.tim-wcx.ltd//img/20211210160608.png" /></p>
<ol>
<li>
<p>透视投影</p>
</li>
<li>
<p>定义：投影中心与投影平面之间的距离为有限</p>
</li>
<li>
<p>灭点（vanishing point）</p>
<div class="codehilite"><pre><span></span><code>不平行于投影平面的平行线，经过透视投影之后收敛于一点，称为灭点。灭点的个数无限
</code></pre></div>

</li>
<li>
<p>主灭点:平行于坐标轴的平行线的灭点。</p>
<p>一点透视：1个灭点</p>
<p>两点透视：2个灭点</p>
<p>三点透视：3个灭点</p>
</li>
<li>
<p>特点</p>
<p>产生近大远小的视觉效果，由它产生的图形深度感强，看起来更加真实。</p>
</li>
<li>
<p>平行投影</p>
</li>
</ol>
<p>投影中心与投影平面之间的距离为无限，是透视投影的极限状态</p>
<ol>
<li>正投影与斜投影</li>
</ol>
<p>正投影(orthogonal projection)：投影线垂直于投影平面</p>
<p>斜投影：投影线不垂直于投影平面</p>
<p>三视图：正视图、侧视图和俯视图，均为正投影。</p>
<p><strong>观察坐标系</strong></p>
<ol>
<li>定义</li>
</ol>
<p>依赖于投影平面建立的三维坐标系uvn。如照相机所在的坐标系。</p>
<ol>
<li>观察坐标系的建立</li>
</ol>
<p>建立观察坐标系
   1. 坐标原点----投影平面（如底片）上的一点，称为观察参考点VRP（View Reference Point)
   2. n轴(VPN)----照相机镜头反方向（投影平面的法向）
   3. v轴----标志物体的朝向，类似照相机向上的方向（观察正向VUP在投影平面上的投影）
   4. u轴,<span class="arithmatex"><span class="MathJax_Preview">u=n \times v</span><script type="math/tex">u=n \times v</script></span></p>
<ol>
<li>观察坐标系中的投影参数</li>
</ol>
<p>简化投影变换</p>
<p>投影平面 ---- n = 0，投影中心 ---- (0 ，0，d )</p>
<p>投影前需要将图形坐标从世界（用户）坐标系转换到观察坐标系。</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210162034.png" alt="image-20211210162033159" style="zoom:67%;" /></p>
<ol>
<li>视见体</li>
</ol>
<p>视见体是三维裁剪窗口，确定可见空间</p>
<p>建立步骤</p>
<p>1 定义窗口（投影平面上）</p>
<p>2 形成观察空间（发出射线）</p>
<p>3 形成视见体（前后裁剪面）</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210162106.png" alt="image-20211210162105948" style="zoom:67%;" /></p>
<ol>
<li>
<p>建立窗口</p>
<p>在投影平面uv上</p>
<p>指定参数（umin，vmin）（umax，vmax)</p>
<p>窗口中心CW不一定落在观察参考点VRP上</p>
<p>只有在窗口内的图形才能在视区中显示</p>
</li>
<li>
<p>生成观察空间</p>
<p>定义投影参考点PRP: Projection Reference Point</p>
<p>作用：确定投影中心（透视投影）或投影方向（平行投影）</p>
<p>透视投影：COP = PRP，观察空间是四棱锥。</p>
<p>平行投影：投影方向DOP = 窗口中心CW - PRP，观察空间是四棱柱。</p>
</li>
<li>
<p>形成视见体</p>
</li>
</ol>
<p>视见体：定义前后裁剪面，形成有限的观察空间</p>
<p>透视投影视见体是四棱台；平行投影视见体是长方体</p>
<p>又称为裁剪空间</p>
<ol>
<li>定义一个视见体所需要的参数</li>
</ol>
<table>
<thead>
<tr>
<th><strong>参数</strong></th>
<th><strong>作用</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>投影类型</td>
<td>定义投影是平行投影还是透视投影</td>
</tr>
<tr>
<td>观察参考点VRP</td>
<td>在世界坐标系中指定，为观察坐标系原点</td>
</tr>
<tr>
<td>观察平面法向VPN</td>
<td>在世界坐标系中指定，为观察坐标的n轴</td>
</tr>
<tr>
<td>观察正向VUP</td>
<td>在世界坐标系中指定，确定观察坐标系的v</td>
</tr>
<tr>
<td>投影参考点PRP</td>
<td>在观察坐标系中指定确定投影中心或投影方向</td>
</tr>
<tr>
<td>前裁剪面裁距F</td>
<td>在观察坐标系中指定，n＝F为前裁剪面</td>
</tr>
<tr>
<td>后裁剪面裁距B</td>
<td>在观察坐标系中指定，n＝B为后裁剪面</td>
</tr>
<tr>
<td>窗口umin，umax、vmin、vmax</td>
<td>在观察坐标系的uv平面上指定，确定窗口与视见体</td>
</tr>
</tbody>
</table>
<p><strong>投影变换</strong></p>
<ol>
<li>透视投影</li>
</ol>
<p>在uvn中，投影平面为n = 0，投影中心为(0，0，d )，投影变换矩阵为：</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210164300.png" alt="image-20211210164258645" style="zoom:80%;" /></p>
<ol>
<li>平行投影</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211210164453.png" alt="image-20211210164453166" style="zoom:80%;" /></p>
<p><strong>从世界坐标系到观察坐标系的变换</strong></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210164703.png" alt="image-20211210164703196" style="zoom:80%;" /></p>
<p><strong>三维图形的显示流程图</strong></p>
<p><img alt="image-20211210165004865" src="https://pic.tim-wcx.ltd//img/20211210165005.png" /></p>
<p>模型变换: 从局部（模型）坐标系到世界坐标系的变换</p>
<p>观察变换: 从世界坐标系到观察坐标系的变换</p>
<p>投影变换 : 三维到二维的转换</p>
<ol>
<li>模型变换</li>
</ol>
<p>将物体从自身的模型坐标系变换到上层物体的模型坐标系（或世界坐标系）的几何变换。</p>
<p>模型变换是构造复杂物体的方法，通过基本几何变换构造复杂物体。</p>
<ol>
<li>
<p>裁剪</p>
</li>
<li>
<p>先投影后裁剪</p>
<p>优点：二维裁剪相对容易
  缺点：需要对所有的物体进行投影变换</p>
</li>
<li>
<p>先裁剪后投影</p>
<ol>
<li>
<p>原因有：</p>
<p>(1) 三维物体的表面通常被离散表示成多边形或折线，而对这类简单图元，三维裁剪同样比较简单;</p>
<p>(2) 三维图形在显示过程中需要被消隐，消隐要有图形的深度信息，所以必须在投影之前完成 。 消隐很费时，如果在此之前裁剪（或部分裁剪）掉不可见的图形，可使需要消隐的图形减至最小。两类投影的视见体不一样，如何方便裁剪？规范化到长方体</p>
</li>
<li>
<p>三维裁剪的两种方法</p>
<p>在三维空间关于视见体裁剪，需要将齐次坐标转换为三维坐标</p>
<p>优点：三维裁剪相对容易</p>
<p>缺点：需要将齐次坐标转换为三维坐标</p>
<p>直接在四维齐次坐标空间中进行裁剪</p>
<p>优点：</p>
<p>不需要将齐次坐标转换为三维坐标</p>
<p>有理曲线曲面可能直接用齐次坐标来表示，对它们的裁剪只能在齐次坐标空间中进行 </p>
<p>缺点：四维裁剪相对复杂</p>
</li>
</ol>
</li>
<li>
<p>直线段裁剪</p>
<ol>
<li>
<p>Cohen_Sutherland算法</p>
<p>视见体是长方体，6个面分空间27个区域</p>
<p>编码：6位，C1C2C3C4C5C6</p>
<p>算法过程： 类似二维裁剪</p>
</li>
<li>
<p>Linang_Barskey算法的直接推广 －三维投影到一维</p>
<p>诱导窗口是3条线段的交集。</p>
</li>
</ol>
</li>
<li>
<p>多边形裁剪：逐面裁剪算法</p>
<ol>
<li>是二维多边形Sutherland_Hodgman逐边裁剪算法推广。</li>
<li>多边形边与裁剪线裁剪扩展为多边形边与裁剪面裁剪。边与裁剪面裁剪时的输出规则与二维类似。</li>
</ol>
</li>
<li>
<p>主要运算： 求线段与平面的交点</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210165732.png" alt="image-20211210165730914" style="zoom: 80%;" /></p>
</li>
</ol>
<p><strong>OpenGL相关函数</strong></p>
<div class="language-c highlight"><pre><span></span><code><span id="__span-4-1"><a id="__codelineno-4-1" name="__codelineno-4-1" href="#__codelineno-4-1"></a><span class="c1">//建模观察模式</span>
</span><span id="__span-4-2"><a id="__codelineno-4-2" name="__codelineno-4-2" href="#__codelineno-4-2"></a><span class="n">glMatrixMode</span><span class="err">（</span><span class="n">GL_MODELVIEW</span><span class="err">）</span>
</span><span id="__span-4-3"><a id="__codelineno-4-3" name="__codelineno-4-3" href="#__codelineno-4-3"></a><span class="n">gluLookAt</span><span class="err">（</span><span class="n">eyex</span><span class="p">,</span><span class="w"> </span><span class="n">eyey</span><span class="p">,</span><span class="w"> </span><span class="n">eyez</span><span class="p">,</span><span class="w"> </span><span class="n">atx</span><span class="p">,</span><span class="w"> </span><span class="n">aty</span><span class="p">,</span><span class="w"> </span><span class="n">atz</span><span class="p">,</span><span class="w"> </span><span class="n">upx</span><span class="p">,</span><span class="w"> </span><span class="n">upy</span><span class="p">,</span><span class="w"> </span><span class="n">upz</span><span class="err">）</span><span class="c1">//指定观察参数</span>
</span><span id="__span-4-4"><a id="__codelineno-4-4" name="__codelineno-4-4" href="#__codelineno-4-4"></a><span class="c1">//默认参数：（1）eye＝（0，0，0）（2）at＝（0，0，－1）（3）up＝（0，1，0）</span>
</span><span id="__span-4-5"><a id="__codelineno-4-5" name="__codelineno-4-5" href="#__codelineno-4-5"></a>
</span><span id="__span-4-6"><a id="__codelineno-4-6" name="__codelineno-4-6" href="#__codelineno-4-6"></a><span class="c1">//建立投影变换矩阵，设定当前投影矩阵</span>
</span><span id="__span-4-7"><a id="__codelineno-4-7" name="__codelineno-4-7" href="#__codelineno-4-7"></a><span class="n">glMatrixMode</span><span class="err">（</span><span class="n">GL_PROJECTION</span><span class="err">）</span>
</span><span id="__span-4-8"><a id="__codelineno-4-8" name="__codelineno-4-8" href="#__codelineno-4-8"></a>
</span><span id="__span-4-9"><a id="__codelineno-4-9" name="__codelineno-4-9" href="#__codelineno-4-9"></a><span class="c1">//正（平行）投影函数</span>
</span><span id="__span-4-10"><a id="__codelineno-4-10" name="__codelineno-4-10" href="#__codelineno-4-10"></a><span class="n">glOrtho</span><span class="p">(</span><span class="n">xmin</span><span class="p">,</span><span class="w"> </span><span class="n">xmax</span><span class="p">,</span><span class="w"> </span><span class="n">ymin</span><span class="p">,</span><span class="w"> </span><span class="n">ymax</span><span class="p">,</span><span class="w"> </span><span class="n">near</span><span class="p">,</span><span class="w"> </span><span class="n">far</span><span class="p">)</span>
</span><span id="__span-4-11"><a id="__codelineno-4-11" name="__codelineno-4-11" href="#__codelineno-4-11"></a><span class="n">或</span><span class="w">  </span><span class="n">glOrtho</span><span class="p">(</span><span class="n">left</span><span class="p">,</span><span class="w"> </span><span class="n">right</span><span class="p">,</span><span class="w"> </span><span class="n">bottom</span><span class="p">,</span><span class="w"> </span><span class="n">top</span><span class="p">,</span><span class="w"> </span><span class="n">near</span><span class="p">,</span><span class="w"> </span><span class="n">far</span><span class="p">)</span>
</span><span id="__span-4-12"><a id="__codelineno-4-12" name="__codelineno-4-12" href="#__codelineno-4-12"></a><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="n">形成视见体</span>
</span><span id="__span-4-13"><a id="__codelineno-4-13" name="__codelineno-4-13" href="#__codelineno-4-13"></a><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="n">near和far为从观察坐标系原点沿负Z轴方向的距离</span>
</span><span id="__span-4-14"><a id="__codelineno-4-14" name="__codelineno-4-14" href="#__codelineno-4-14"></a><span class="n">默认参数</span><span class="err">：</span><span class="n">glOrtho</span><span class="p">(</span><span class="mf">-1.0</span><span class="p">,</span><span class="w"> </span><span class="mf">1.0</span><span class="p">,</span><span class="w"> </span><span class="mf">-1.0</span><span class="p">,</span><span class="w"> </span><span class="mf">1.0</span><span class="p">,</span><span class="w"> </span><span class="mf">-1.0</span><span class="p">,</span><span class="w"> </span><span class="mf">1.0</span><span class="p">)</span><span class="n">是一对称规范化对称正方体</span>
</span><span id="__span-4-15"><a id="__codelineno-4-15" name="__codelineno-4-15" href="#__codelineno-4-15"></a><span class="n">对二维而言</span><span class="err">，</span><span class="w"> </span><span class="n">glOrtho2D建立裁剪窗口</span>
</span><span id="__span-4-16"><a id="__codelineno-4-16" name="__codelineno-4-16" href="#__codelineno-4-16"></a><span class="n">如不指定投影函数</span><span class="err">，</span><span class="n">默认正投影来显示场景</span>
</span><span id="__span-4-17"><a id="__codelineno-4-17" name="__codelineno-4-17" href="#__codelineno-4-17"></a>
</span><span id="__span-4-18"><a id="__codelineno-4-18" name="__codelineno-4-18" href="#__codelineno-4-18"></a><span class="c1">//透视投影函数定义视见体   </span>
</span><span id="__span-4-19"><a id="__codelineno-4-19" name="__codelineno-4-19" href="#__codelineno-4-19"></a><span class="n">glFrustum</span><span class="p">(</span><span class="w"> </span><span class="n">left</span><span class="p">,</span><span class="w"> </span><span class="n">right</span><span class="p">,</span><span class="w"> </span><span class="n">bottom</span><span class="p">,</span><span class="w"> </span><span class="n">top</span><span class="p">,</span><span class="w"> </span><span class="n">near</span><span class="p">,</span><span class="w"> </span><span class="n">far</span><span class="p">)</span>
</span><span id="__span-4-20"><a id="__codelineno-4-20" name="__codelineno-4-20" href="#__codelineno-4-20"></a><span class="n">定义视见体</span>
</span><span id="__span-4-21"><a id="__codelineno-4-21" name="__codelineno-4-21" href="#__codelineno-4-21"></a><span class="w"> </span><span class="n">前四个参数设定投影平面上</span>
</span><span id="__span-4-22"><a id="__codelineno-4-22" name="__codelineno-4-22" href="#__codelineno-4-22"></a><span class="n">裁剪窗口的坐标</span>
</span><span id="__span-4-23"><a id="__codelineno-4-23" name="__codelineno-4-23" href="#__codelineno-4-23"></a><span class="err">（</span><span class="n">OpenGL投影平面为近裁剪面</span><span class="err">）</span>
</span><span id="__span-4-24"><a id="__codelineno-4-24" name="__codelineno-4-24" href="#__codelineno-4-24"></a>
</span><span id="__span-4-25"><a id="__codelineno-4-25" name="__codelineno-4-25" href="#__codelineno-4-25"></a><span class="n">gluPerspective</span><span class="err">（</span><span class="n">fovy</span><span class="err">，</span><span class="n">aspect</span><span class="err">，</span><span class="n">near</span><span class="err">，</span><span class="n">far</span><span class="err">）</span>
</span><span id="__span-4-26"><a id="__codelineno-4-26" name="__codelineno-4-26" href="#__codelineno-4-26"></a><span class="n">fovy</span><span class="err">：</span><span class="n">上下裁剪面间的夹角</span><span class="err">（</span><span class="mi">0</span><span class="err">～</span><span class="mi">180</span><span class="err">）</span>
</span><span id="__span-4-27"><a id="__codelineno-4-27" name="__codelineno-4-27" href="#__codelineno-4-27"></a><span class="n">aspect</span><span class="err">：</span><span class="n">裁剪窗口纵横比</span><span class="err">（</span><span class="n">宽度</span><span class="o">/</span><span class="n">高度</span><span class="err">）</span>
</span><span id="__span-4-28"><a id="__codelineno-4-28" name="__codelineno-4-28" href="#__codelineno-4-28"></a><span class="n">near</span><span class="err">：</span><span class="n">近裁剪面</span>
</span><span id="__span-4-29"><a id="__codelineno-4-29" name="__codelineno-4-29" href="#__codelineno-4-29"></a><span class="n">far</span><span class="err">：</span><span class="n">远剪面</span>
</span></code></pre></div>
<h3 id="_8">第八章   真实感图形生成<a class="headerlink" href="#_8" title="Permanent link">&para;</a></h3>
<p><strong>消隐技术</strong></p>
<ol>
<li>
<p>定义：消除被遮挡的不可见的线或面称作消除隐藏线和隐藏面，简称为消隐。</p>
</li>
<li>
<p>消隐的对象：三维物体，三维体的表示主要采用边界（多边形）表示。</p>
</li>
<li>
<p>消隐结果：与观察物体有关，也与视点位置和方向有关。</p>
</li>
<li>
<p>画家算法</p>
</li>
<li>
<p>定义：远近排序，之后按远近顺序投影。</p>
</li>
<li>
<p>问题：不能处理多边形循环遮挡和多边形相互穿透。</p>
</li>
<li>
<p>Z （深度）缓冲器算法</p>
</li>
<li>
<p>组成</p>
<p>帧缓冲器 -- 保存各像素颜色值，Z 缓冲器  -- 保存各像素处物体深度值</p>
<p>Z 缓冲器中的单元与帧缓冲器中的单元一一对应</p>
</li>
<li>
<p>算法步骤</p>
<p>(1) 先将 Z 缓冲器中个单元的初始值置为最小值。</p>
<p>(2)多边形投影后，扫描转换写帧缓存时，当要改变某个像素的颜色值时，首先检查该像素对应当前多边形上点的深度值是否大于该像素原来的深度值（保存在该像素所对应的Z缓冲器的单元中），</p>
<p>如果大于，说明当前多边形更靠近观察点，用它的颜色替换像素原来的颜色；同时保存深度值;</p>
<p>否则说明在当前像素处，当前多边形被前面所绘制的多边形遮挡了，是不可见的，像素的颜色值不改变。</p>
</li>
<li>
<p>特点</p>
<p>(1) Z 缓冲器算法是所有图像空间算法中最简单的一种隐藏面消除算法。在像素级上以近物取代远物，与形体在屏幕上的出现顺序无关。</p>
<p>(2) 优点</p>
<p>简单稳定，利于硬件实现、不需要整个场景的几何数据
  (3) 缺点</p>
<p>需要一个额外的 Z 缓冲器、每个多边形占据的每个像素处都要计算深度值，计算量大</p>
</li>
<li>
<p>OpenGL相关函数</p>
<div class="language-c highlight"><pre><span></span><code><span id="__span-5-1"><a id="__codelineno-5-1" name="__codelineno-5-1" href="#__codelineno-5-1"></a><span class="n">glClear</span><span class="p">(</span><span class="w"> </span><span class="n">GL_DEPTH_BUFFER_BIT</span><span class="p">)</span><span class="w"> </span><span class="c1">//深度缓存初始化</span>
</span><span id="__span-5-2"><a id="__codelineno-5-2" name="__codelineno-5-2" href="#__codelineno-5-2"></a><span class="err">（</span><span class="mi">1</span><span class="err">）</span><span class="n">在每显示新的一帧前清除</span>
</span><span id="__span-5-3"><a id="__codelineno-5-3" name="__codelineno-5-3" href="#__codelineno-5-3"></a><span class="err">（</span><span class="mi">2</span><span class="err">）</span><span class="n">设置的默认值为1</span>
</span><span id="__span-5-4"><a id="__codelineno-5-4" name="__codelineno-5-4" href="#__codelineno-5-4"></a><span class="err">（</span><span class="mi">3</span><span class="err">）</span><span class="n">设置初始值</span><span class="err">：</span><span class="n">glClearDepth</span><span class="err">（</span><span class="n">maxDepth</span><span class="err">）</span>
</span><span id="__span-5-5"><a id="__codelineno-5-5" name="__codelineno-5-5" href="#__codelineno-5-5"></a><span class="err">（</span><span class="mi">4</span><span class="err">）</span><span class="n">OpenGL允许每个像素的深度范围是0</span><span class="p">.</span><span class="mf">.1</span><span class="err">，</span><span class="n">最大值为1为最远点</span><span class="err">，</span><span class="n">前面物体深度值小</span><span class="err">。</span>
</span><span id="__span-5-6"><a id="__codelineno-5-6" name="__codelineno-5-6" href="#__codelineno-5-6"></a><span class="n">glEnable</span><span class="p">(</span><span class="n">GL_DEPTH_TEST</span><span class="p">);</span><span class="c1">//激活函数(默认为不激活）</span>
</span><span id="__span-5-7"><a id="__codelineno-5-7" name="__codelineno-5-7" href="#__codelineno-5-7"></a><span class="n">深度测试比较</span><span class="err">：</span><span class="n">glDepthFunc</span><span class="p">(</span><span class="n">mode</span><span class="p">)</span><span class="err">，</span><span class="n">mode取GL_LESS</span><span class="w"> </span><span class="n">时</span><span class="err">，</span><span class="n">深度值小</span><span class="err">（</span><span class="n">近处</span><span class="err">）</span><span class="n">的显示</span><span class="err">；</span><span class="n">取GL_GREATER</span><span class="w"> </span><span class="n">时</span><span class="err">，</span><span class="n">深度值大</span><span class="err">（</span><span class="n">远处</span><span class="err">）</span><span class="n">的显示</span><span class="err">。</span>
</span></code></pre></div>
</li>
</ol>
<p><strong>简单光照模型</strong></p>
<ol>
<li>引言</li>
<li>光作用：反射、透射（透明物体）、被物体吸收转化为热能</li>
<li>假设：物体不透明，即没有透射光</li>
<li>
<p>光种类：环境光、漫反射光和镜面反射光</p>
</li>
<li>
<p>环境光</p>
</li>
</ol>
<p>在物体和周围环境之间多次反射后，最终达到平衡时的一种光，又称为背景光</p>
<p>光强（度）：空间上分布均匀，即任何位置和方向光强度一样，亮度值记为<span class="arithmatex"><span class="MathJax_Preview">I_a</span><script type="math/tex">I_a</script></span></p>
<p>反射系数：与物体表面性质有关，决定物体表面呈现的亮度，记为<span class="arithmatex"><span class="MathJax_Preview">K_a</span><script type="math/tex">K_a</script></span></p>
<p>光照模型方程<span class="arithmatex"><span class="MathJax_Preview">I_e = K_α*I_α</span><script type="math/tex">I_e = K_α*I_α</script></span>，<span class="arithmatex"><span class="MathJax_Preview">I_e</span><script type="math/tex">I_e</script></span>为物体表面呈现的亮度。</p>
<p>(<span class="arithmatex"><span class="MathJax_Preview">I_a</span><script type="math/tex">I_a</script></span>可以看着是颜色的分量；<span class="arithmatex"><span class="MathJax_Preview">K_a</span><script type="math/tex">K_a</script></span> 为对应的分量反射系数）</p>
<ol>
<li>漫反射</li>
<li>
<p>点光源：向周围所有方向发射等强度的光。</p>
</li>
<li>
<p>漫反射光是由物体表面的粗糙不平引起的，它均匀地向各个方向传播，与视点位置无关。</p>
</li>
<li>
<p>漫反射光在空间均匀分布，反射光强 I 与入射光的入射角θ 的余弦成正比，即：<span class="arithmatex"><span class="MathJax_Preview">I_d=K_d*I_p*cos \theta</span><script type="math/tex">I_d=K_d*I_p*cos \theta</script></span></p>
<p>其中，Kd 是漫反射系数（0～1之间的常数），与物体表面性质有关；Ip 是光源的光强；θ是入射光的入射角，即入射光与物体表面法向量之间的夹角。</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210144023.png" alt="image-20211210144022568" style="zoom:80%;" /></p>
</li>
<li>
<p>向量计算</p>
<p>设物体表面在照射点 P 处的单位法向量为N，P 到点光源的单位向量为L，则上式可表达为如下的向量形式：<span class="arithmatex"><span class="MathJax_Preview">I_d=K_d*I_p*(N\cdot L)</span><script type="math/tex">I_d=K_d*I_p*(N\cdot L)</script></span></p>
</li>
<li>
<p>多个光源</p>
<p>把各个光源的漫反射光照效果进行叠加：<span class="arithmatex"><span class="MathJax_Preview">I_d=K_d*\sum_{i=1}^mI_{pi}*(N \cdot L_i)</span><script type="math/tex">I_d=K_d*\sum_{i=1}^mI_{pi}*(N \cdot L_i)</script></span></p>
</li>
<li>
<p>漫反射光和环境光相结合</p>
</li>
</ol>
<p><span class="arithmatex"><span class="MathJax_Preview">I=I_e+I_d=I_α I_α+I_p I_d (L∙N)</span><script type="math/tex">I=I_e+I_d=I_α I_α+I_p I_d (L∙N)</script></span></p>
<ol>
<li>
<p>镜面反射光和冯（Phong）反射模型</p>
</li>
<li>
<p>高光（high light）：光滑物体表面在点光源的照射下形成一块特别亮的区域</p>
</li>
<li>
<p>镜面反射（Specular Reflection）</p>
<p>物体表面对入射光的反射</p>
<p>遵循反射定律</p>
<p>（1）反射光与入射光位于表面法向两侧</p>
<p>（2）理想反射面而言：入射角＝反射角</p>
<p>观察者在反射方向上看到反射光最强</p>
</li>
<li>
<p>Phong模型</p>
<p>计算公式：<span class="arithmatex"><span class="MathJax_Preview">I_s=I_p K_s cos ^n \alpha =I_P K_s (N \cdot R) ^n</span><script type="math/tex">I_s=I_p K_s cos ^n \alpha =I_P K_s (N \cdot R) ^n</script></span></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210145233.png" alt="image-20211210145233372" style="zoom: 67%;" /></p>
<p>Ks是物体表面镜面反射系数，它与物体属性有关；</p>
<p>α 是视线与反射方向的夹角；</p>
<p>n 为镜面高光系数，用来模拟镜面反射光在空间中的汇聚程度，它是一个反映物体表面光泽度的常数；</p>
<p>$cos^n \alpha $近似地描述了镜面反射光的空间分布。</p>
<p>n越大，高光区域衰减越快，高光区域越小，常规取值 5-20。</p>
</li>
<li>
<p>简化Phong模型</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210145723.png" alt="image-20211210145723103" style="zoom:80%;" /></p>
</li>
<li>
<p>局部光照方程</p>
<p><span class="arithmatex"><span class="MathJax_Preview">I=I_{\alpha}+I_d+I_s=K_{\alpha}I_{\alpha}+I_p[K_d(N \cdot L)+K_s(H \cdot N) ^n]</span><script type="math/tex">I=I_{\alpha}+I_d+I_s=K_{\alpha}I_{\alpha}+I_p[K_d(N \cdot L)+K_s(H \cdot N) ^n]</script></span></p>
<p>当光源和视点无穷远时，对表面上任意一点而言，L和V固定不变，H只需计算一次。</p>
</li>
<li>
<p>产生颜色</p>
</li>
</ol>
<p>前面的光照模型仅用于白光，只能产生灰度</p>
<p>彩色模型计算</p>
<p>选择合适模型（如RGB、HSV等），为颜色的三个分量分别建立光照方程。</p>
<p>RGB模型</p>
<p>光源的颜色<span class="arithmatex"><span class="MathJax_Preview">[I_{pR}, I_{pG}, I_{pB}]</span><script type="math/tex">[I_{pR}, I_{pG}, I_{pB}]</script></span>，环境光的颜色<span class="arithmatex"><span class="MathJax_Preview">[I_{aR}, I_{aG}, I_{aB}]</span><script type="math/tex">[I_{aR}, I_{aG}, I_{aB}]</script></span></p>
<p>表面反射系数</p>
<p>（1）环境反射： [KaR, KaG, KaB]</p>
<p>（2）漫反射：     [KdR, KdG, KdB]</p>
<p>（3）镜面反射： [KsR, KsG, KsB]</p>
<p>彩色光照方程（模型） f(d)为光的衰减</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210150444.png" alt="image-20211210150443517" style="zoom:80%;" /></p>
<ol>
<li>多个光源</li>
</ol>
<p>如果场景中有m个光源，那么物体上任一点的亮度应该为m个光源的贡献之和。</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210150633.png" alt="image-20211210150633747" style="zoom:80%;" /></p>
<p>在RGB彩色模型中，λ分别为R、G和B。</p>
<p>​      注意：Iλ可能会超出系统允许的最大亮度值，处理方法</p>
<p>​     （1）截去超出部分，设置为最大值</p>
<p>​   （2）首先计算出所有亮度值，再进行变换（如缩放变换）使其落在系统规定范围之内</p>
<ol>
<li>OpenGL相关函数</li>
</ol>
<div class="language-C highlight"><pre><span></span><code><span id="__span-6-1"><a id="__codelineno-6-1" name="__codelineno-6-1" href="#__codelineno-6-1"></a><span class="kt">void</span><span class="w"> </span><span class="n">glLight</span><span class="p">{</span><span class="k">if</span><span class="p">}[</span><span class="n">v</span><span class="p">](</span><span class="n">GLenum</span><span class="w"> </span><span class="n">light</span><span class="w"> </span><span class="p">,</span><span class="w"> </span><span class="n">GLenum</span><span class="w"> </span><span class="n">pname</span><span class="p">,</span><span class="w"> </span><span class="n">TYPE</span><span class="w"> </span><span class="n">param</span><span class="p">);</span><span class="w"> </span><span class="c1">//创建光源</span>
</span><span id="__span-6-2"><a id="__codelineno-6-2" name="__codelineno-6-2" href="#__codelineno-6-2"></a><span class="kt">void</span><span class="w"> </span><span class="n">glMaterial</span><span class="p">{</span><span class="k">if</span><span class="p">}[</span><span class="n">v</span><span class="p">](</span><span class="n">GLenum</span><span class="w"> </span><span class="n">face</span><span class="p">,</span><span class="w"> </span><span class="n">GLenum</span><span class="w"> </span><span class="n">pname</span><span class="p">,</span><span class="w"> </span><span class="n">TYPE</span><span class="w"> </span><span class="n">param</span><span class="p">);</span><span class="w"> </span><span class="c1">//设置材质</span>
</span><span id="__span-6-3"><a id="__codelineno-6-3" name="__codelineno-6-3" href="#__codelineno-6-3"></a><span class="n">glEnable</span><span class="p">(</span><span class="n">GL_LIGHTING</span><span class="p">);</span><span class="w"> </span><span class="c1">//开启光源</span>
</span><span id="__span-6-4"><a id="__codelineno-6-4" name="__codelineno-6-4" href="#__codelineno-6-4"></a><span class="n">glEnable</span><span class="p">(</span><span class="n">GL_LIGHT0</span><span class="p">);</span><span class="w"> </span><span class="c1">//开启光源</span>
</span></code></pre></div>
<p><strong>多边形绘制方法</strong></p>
<ol>
<li>
<p>当绘制多边形时入射光矢量及反射光与视线夹角不同，所以颜色不同。</p>
</li>
<li>
<p>多边形均匀着色</p>
</li>
<li>
<p>方法</p>
<p>任取多边形上一点，利用光照明方程计算出它的颜色</p>
<p>用这个颜色填充整个多边形</p>
</li>
<li>
<p>适合于如下情况</p>
<p>光源在无穷远处，L·N 相等</p>
<p>视点在无穷远处，H·N 相等</p>
<p>多边形是物体表面的精确表示（多边形面积足够小）</p>
</li>
<li>
<p>特点</p>
<p>优点：每个多边形只需计算一次光照明方程，速度快</p>
<p>缺点：相邻多边形颜色过渡不光滑</p>
</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211210151126.png" alt="image-20211210151126869" style="zoom: 80%;" /></p>
<ol>
<li>Gouraud 着色方法（颜色插值方法）</li>
</ol>
<p>主要步骤</p>
<p>（1）计算多边形的单位法向量</p>
<p>（2）计算多边形顶点的单位法向量（共享顶点的多边形法向量的平均值）</p>
<p>（3）利用光照明方程计算顶点颜色</p>
<p>（4）对多边形顶点颜色进行双线性插值，获得多边形内部各点的颜色
   1. 计算多边形单位法向量</p>
<div class="codehilite"><pre><span></span><code>  &lt;img src=&quot;https://pic.tim-wcx.ltd//img/20211210151447.png&quot; alt=&quot;image-20211210151447383&quot; style=&quot;zoom:67%;&quot; /&gt;
</code></pre></div>

<ol>
<li>
<p>内部点颜色计算：双线性插值</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210151534.png" alt="image-20211210151534532" style="zoom:80%;" /></p>
<ol>
<li>
<p>增量法优化</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210185029.png" alt="image-20211210151616893" style="zoom:80%;" /></p>
</li>
</ol>
</li>
<li>
<p>Phong 着色方法（法向插值着色方法）
   方法：通过对多边形顶点法向量进行插值，获得多边形内    部各点的法向量，再利用光照方程计算各点的亮度</p>
</li>
</ol>
<p>主要步骤：</p>
<p>（1）计算多边形单位法向量</p>
<p>（2）计算多边形顶点单位法向量（以上两步同Gouraud着色方法）</p>
<p>（3）对多边形顶点法向量进行双线性插值，获得内部各点的法向量</p>
<p>（4）利用光照明方程计算多边形内部各点颜色</p>
<p>Phong插值优化同高洛德，只是将颜色插值替换为向量插值，扫描线优化同，在此省略，</p>
<ol>
<li>
<p>均匀着色、Gouraud 和Phong方法比较</p>
<p>（1）均匀着色（Flat）块状现象明显，计算开销小</p>
<p>（2） Gouraud方法光变化过渡不连续，计算开销较大</p>
<p>（3）Phong方法光变化过渡连续，计算开销大</p>
</li>
</ol>
<p><strong>纹理映射</strong></p>
<ol>
<li>引言</li>
</ol>
<p>光照模型只能生成光滑的物体表面</p>
<p>自然界中的物体表面具有丰富的细节，如木纹、桔子凹凸表面、沙砾路面</p>
<p>丰富的表面细节难以用计算机图形方法生成</p>
<p>采用将图片贴到物体表面上的方法绘制</p>
<ol>
<li>什么是纹理？</li>
</ol>
<p>是物体表面的细小结构，它可以是光滑表面的花纹、图案，即颜色纹理(2D)。</p>
<p>纹理也可以是物体表面的三维结构</p>
<p>纹理还可以是粗糙的表面(如桔子表面的皱纹)，称为几何纹理，是基于物体表面的微观几何形状的表面纹理。</p>
<ol>
<li>纹理空间：纹理图案所在空间，记为st坐标系（一般是平面）</li>
</ol>
<p>纹素（texel）：纹理最小单元，位置由纹理坐标（s，t）标识</p>
<p>纹理坐标s，t：0到1间取值</p>
<p>图像像素坐标规范化到[0…1]区间。规范化后方便使用纹理坐标。</p>
<ol>
<li>纹理来源</li>
</ol>
<p>数字图像，用二维数组表示</p>
<p>数学公式定义纹理</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210152502.png" alt="image-20211210152502478" style="zoom:67%;" /></p>
<ol>
<li>
<p>纹理映射（Texture Mapping）</p>
</li>
<li>
<p>定义：将纹理图案映射到物体表面上，产生物体表面细节的过程</p>
</li>
<li>
<p>颜色计算方法</p>
<p>(1) 用表面上点对应的纹素值代替该点的漫反射系数</p>
<p>(2) 用表面上点对应的纹素值代替该点的颜色值</p>
</li>
<li>
<p>纹理坐标：确定纹理与物体表面的对应关系（纹素与顶点），变化范围[0,1]。多边形每个顶点对应一个纹素，内部点插值计算对应纹素。</p>
</li>
<li>
<p>圆柱曲面纹理映射</p>
<p><span class="arithmatex"><span class="MathJax_Preview">P(\theta,y)=(r cos \theta,r sin \theta),-\frac{h}{2}\leq y \leq \frac{h}{2}</span><script type="math/tex">P(\theta,y)=(r cos \theta,r sin \theta),-\frac{h}{2}\leq y \leq \frac{h}{2}</script></span></p>
<p>对应的纹理坐标：<span class="arithmatex"><span class="MathJax_Preview">s=\frac{\theta}{360},t=\frac{y+\frac{h}{2}}{h}</span><script type="math/tex">s=\frac{\theta}{360},t=\frac{y+\frac{h}{2}}{h}</script></span></p>
</li>
<li>
<p>球面曲面纹理映射</p>
<p><span class="arithmatex"><span class="MathJax_Preview">p(\theta,\phi)=(rcos\theta cos\phi,rsin \phi,rsin\theta cos\phi)</span><script type="math/tex">p(\theta,\phi)=(rcos\theta cos\phi,rsin \phi,rsin\theta cos\phi)</script></span></p>
<p>θ和φ变化范围分别[0,360]和[-90,90]</p>
<p>对应的纹理坐标：<span class="arithmatex"><span class="MathJax_Preview">s=\frac{\theta }{360},t=\frac{\phi}{180}+\frac{1}{2}</span><script type="math/tex">s=\frac{\theta }{360},t=\frac{\phi}{180}+\frac{1}{2}</script></span></p>
<p><span class="arithmatex"><span class="MathJax_Preview">s=\frac{\theta }{360},t=\frac{sin \phi }{2}+\frac{1}{2}</span><script type="math/tex">s=\frac{\theta }{360},t=\frac{sin \phi }{2}+\frac{1}{2}</script></span></p>
</li>
<li>
<p>圆环面</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210153914.png" alt="image-20211210153912645" style="zoom:67%;" /></p>
</li>
<li>
<p>OpenGL函数</p>
</li>
<li>
<p>简介</p>
<p>纹理映射是一个相当复杂的过程，最基本的执行纹理映射所需的步骤。基本步骤如下：</p>
<p>（1）定义纹理；给纹理数据</p>
<p>（2）控制滤波；重采样方式</p>
<p>（3）说明映射方式；</p>
<p>（4）激活纹理；</p>
<p>（5）绘制图形时需进行纹理映射，即给出顶点的纹理坐标和几何坐标。</p>
<p>​          注意：纹理映射只能在RGBA方式下执行，不能运用于颜色表方式。 </p>
</li>
</ol>
<div class="language-c highlight"><pre><span></span><code><span id="__span-7-1"><a id="__codelineno-7-1" name="__codelineno-7-1" href="#__codelineno-7-1"></a><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="n">定义纹理</span>
</span><span id="__span-7-2"><a id="__codelineno-7-2" name="__codelineno-7-2" href="#__codelineno-7-2"></a><span class="n">glGenTextures</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">uiTexture</span><span class="p">);</span><span class="c1">// GLuint uiTexture</span>
</span><span id="__span-7-3"><a id="__codelineno-7-3" name="__codelineno-7-3" href="#__codelineno-7-3"></a><span class="kt">void</span><span class="w"> </span><span class="nf">glTexImage2D</span><span class="p">(</span><span class="n">GLenum</span><span class="w"> </span><span class="n">target</span><span class="p">,</span><span class="w"> </span><span class="n">GLint</span><span class="w"> </span><span class="n">level</span><span class="p">,</span><span class="w"> </span>
</span><span id="__span-7-4"><a id="__codelineno-7-4" name="__codelineno-7-4" href="#__codelineno-7-4"></a><span class="n">Glint</span><span class="w"> </span><span class="n">components</span><span class="p">,</span><span class="w"> </span><span class="n">GLsizei</span><span class="w"> </span><span class="n">width</span><span class="p">,</span><span class="w">  </span><span class="n">glsizei</span><span class="w"> </span><span class="n">height</span><span class="p">,</span><span class="w"> </span><span class="n">GLint</span><span class="w"> </span><span class="n">border</span><span class="p">,</span>
</span><span id="__span-7-5"><a id="__codelineno-7-5" name="__codelineno-7-5" href="#__codelineno-7-5"></a><span class="n">GLenum</span><span class="w"> </span><span class="n">format</span><span class="p">,</span><span class="w"> </span><span class="n">GLenum</span><span class="w"> </span><span class="n">type</span><span class="p">,</span><span class="w">  </span><span class="k">const</span><span class="w"> </span><span class="n">GLvoid</span><span class="w"> </span><span class="o">*</span><span class="n">pixels</span><span class="p">);</span>
</span><span id="__span-7-6"><a id="__codelineno-7-6" name="__codelineno-7-6" href="#__codelineno-7-6"></a><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="n">绑定图片</span>
</span><span id="__span-7-7"><a id="__codelineno-7-7" name="__codelineno-7-7" href="#__codelineno-7-7"></a><span class="n">gluBuild2DMipmaps</span><span class="w"> </span><span class="p">(</span><span class="n">GLenum</span><span class="w"> </span><span class="n">target</span><span class="p">,</span><span class="w"> </span><span class="n">Glint</span><span class="w"> </span><span class="n">components</span><span class="p">,</span><span class="w"> </span><span class="n">GLsizei</span><span class="w"> </span><span class="n">width</span><span class="p">,</span><span class="w">  </span><span class="n">glsizei</span><span class="w"> </span><span class="n">height</span><span class="p">,</span><span class="w"> </span><span class="n">GLenum</span><span class="w"> </span><span class="n">format</span><span class="p">,</span><span class="w"> </span><span class="n">GLenum</span><span class="w"> </span><span class="n">type</span><span class="p">,</span><span class="w">  </span><span class="k">const</span><span class="w"> </span><span class="n">GLvoid</span><span class="w"> </span><span class="o">*</span><span class="n">pixels</span><span class="p">);</span>
</span><span id="__span-7-8"><a id="__codelineno-7-8" name="__codelineno-7-8" href="#__codelineno-7-8"></a><span class="p">(</span><span class="mi">3</span><span class="p">)</span><span class="n">控制滤波</span>
</span><span id="__span-7-9"><a id="__codelineno-7-9" name="__codelineno-7-9" href="#__codelineno-7-9"></a><span class="kt">void</span><span class="w"> </span><span class="n">glTexParameter</span><span class="p">{</span><span class="k">if</span><span class="p">}[</span><span class="n">v</span><span class="p">](</span><span class="n">GLenum</span><span class="w"> </span><span class="n">target</span><span class="p">,</span><span class="w"> </span><span class="n">GLenum</span><span class="w"> </span><span class="n">pname</span><span class="p">,</span><span class="w"> </span><span class="n">TYPE</span><span class="w"> </span><span class="n">param</span><span class="p">);</span><span class="w"> </span>
</span><span id="__span-7-10"><a id="__codelineno-7-10" name="__codelineno-7-10" href="#__codelineno-7-10"></a><span class="p">(</span><span class="mi">4</span><span class="p">)</span><span class="n">设置纹理映射方式</span>
</span><span id="__span-7-11"><a id="__codelineno-7-11" name="__codelineno-7-11" href="#__codelineno-7-11"></a><span class="kt">void</span><span class="w"> </span><span class="n">glTexEnv</span><span class="p">{</span><span class="k">if</span><span class="p">}[</span><span class="n">v</span><span class="p">](</span><span class="n">GLenum</span><span class="w"> </span><span class="n">target</span><span class="p">,</span><span class="w"> </span><span class="n">GLenum</span><span class="w"> </span><span class="n">pname</span><span class="p">,</span><span class="n">TYPE</span><span class="w"> </span><span class="n">param</span><span class="p">);</span>
</span><span id="__span-7-12"><a id="__codelineno-7-12" name="__codelineno-7-12" href="#__codelineno-7-12"></a><span class="p">(</span><span class="mi">5</span><span class="p">)</span><span class="n">激活纹理</span>
</span><span id="__span-7-13"><a id="__codelineno-7-13" name="__codelineno-7-13" href="#__codelineno-7-13"></a><span class="n">glEnable</span><span class="p">(</span><span class="n">GL_TEXTURE_2D</span><span class="p">);</span>
</span><span id="__span-7-14"><a id="__codelineno-7-14" name="__codelineno-7-14" href="#__codelineno-7-14"></a><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="n">定义纹理坐标</span>
</span><span id="__span-7-15"><a id="__codelineno-7-15" name="__codelineno-7-15" href="#__codelineno-7-15"></a><span class="kt">void</span><span class="w"> </span><span class="n">glTexCoord</span><span class="p">{</span><span class="mi">1234</span><span class="p">}{</span><span class="n">sifd</span><span class="p">}[</span><span class="n">v</span><span class="p">](</span><span class="n">TYPE</span><span class="w"> </span><span class="n">coords</span><span class="p">);</span><span class="w"> </span>
</span><span id="__span-7-16"><a id="__codelineno-7-16" name="__codelineno-7-16" href="#__codelineno-7-16"></a><span class="n">注意</span><span class="err">：</span><span class="n">使用多个纹理时</span><span class="err">，</span><span class="n">需要在定义点纹理坐标之前</span><span class="err">，</span><span class="n">指定所用纹理</span><span class="err">。</span><span class="n">glBindTexture</span><span class="p">(</span><span class="n">GL_TEXTURE_2D</span><span class="p">,</span><span class="w"> </span><span class="n">id</span><span class="p">);</span>
</span></code></pre></div>
<p><strong>阴影</strong></p>
<ol>
<li>阴影（Shadow）</li>
</ol>
<p>光源不能直接照射到的区域</p>
<p>特点</p>
<p>位于阴影区域中的物体表面被位于它和光源间的物体所遮挡</p>
<p>对光源而言，位于阴影中的物体表面即是不可见面</p>
<p>生成算法：与消隐算法本质上一致</p>
<ol>
<li>具有阴影效果的光照模型</li>
</ol>
<p>光源对位于阴影中的点的亮度（颜色）没有贡献</p>
<p>（1）多光源（2）颜色分量</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210154802.png" alt="image-20211210154802234" style="zoom:80%;" /></p>
<ol>
<li>Z缓冲器阴影算法
     步骤</li>
</ol>
<p>（1）将图形变换到以光源为原点的坐标系，利用Z缓冲器消隐算法，按光线方向对图形消隐，把距光源最近的物体表面上点的深度值保存在Z缓冲器中（称为阴影缓冲器）</p>
<p>（2）利用Z缓冲器消隐算法按视线方向对图形消隐，将得到的每个可见点变换到第 i 个光源的坐标系中，若它在光源坐标系中的深度值小于阴影缓冲器中相应单元的值，则该可见点位于阴影中（Si＝0），否则（ Si ＝1），再用光照模型计算颜色。</p>
<p>特点：算法简单，计算量小，能处理复杂景物；</p>
<p>缺点是每个光源需要1个Z缓冲器，需要的存储空间大</p>
<p>提高消隐算法效率的常用方法：连贯性、包围盒技术、背面剔除、区域分割技术、物体分层表示等。</p>
<h3 id="_9">第九章  曲线与曲面<a class="headerlink" href="#_9" title="Permanent link">&para;</a></h3>
<p><strong>参数曲线基础</strong></p>
<ol>
<li>曲线的表示形式</li>
</ol>
<p>主要有：非参数表示和参数表示</p>
<ol>
<li>
<p>非参数表示</p>
<p>（1）显式表示</p>
<p>坐标间建立函数关系</p>
<p>不能建立多值曲线</p>
<p><span class="arithmatex"><span class="MathJax_Preview">y=f(x),z=g(x)</span><script type="math/tex">y=f(x),z=g(x)</script></span></p>
<p>（2）隐式表示</p>
<p>看做是两曲面的交</p>
<p>可以建立多值曲线</p>
<p>坐标计算相对较复杂</p>
<p><span class="arithmatex"><span class="MathJax_Preview">x^2+y^2=9,z=0</span><script type="math/tex">x^2+y^2=9,z=0</script></span></p>
<p><span class="arithmatex"><span class="MathJax_Preview">f(x,y,z)=0,g(x,y,z)=0</span><script type="math/tex">f(x,y,z)=0,g(x,y,z)=0</script></span></p>
</li>
<li>
<p>参数表示</p>
<p>参数方程：<span class="arithmatex"><span class="MathJax_Preview">x=x(t),y=y(t),z=z(t),t \in [a,b]</span><script type="math/tex">x=x(t),y=y(t),z=z(t),t \in [a,b]</script></span></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210180135.png" alt="image-20211210180133753" style="zoom: 80%;" /></p>
</li>
<li>
<p>参数表示的优点</p>
<p>容易确定曲线边界。由参数区间确定</p>
<p>表示形式不变性。不依赖于坐标系的选取</p>
<p>表示能力强。利于控制点来控制曲线形状，如后面将要学到的Bezier曲线</p>
</li>
<li>
<p>参数表示的优点</p>
<p>容易确定曲线边界。由参数区间确定</p>
<p>表示形式不变性。不依赖于坐标系的选取</p>
<p>表示能力强。利于控制点来控制曲线形状，如后面将要学到的Bezier曲线</p>
</li>
</ol>
<p><strong>切矢量、法矢量、曲率</strong></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210181523.png" alt="image-20211210181522078" style="zoom: 67%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210181733.png" alt="image-20211210181733142" style="zoom: 67%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210182126.png" alt="image-20211210182126504" style="zoom:67%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210210313.png" alt="image-20211210210311486" style="zoom: 50%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210210455.png" alt="image-20211210210455371" style="zoom: 50%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210210558.png" alt="image-20211210210558782" style="zoom: 50%;" /></p>
<p><strong>参数连续性</strong>
传统的、严格的连续性
曲线 P = P(t) 在  t＝t0   处n阶参数连续，如果它在 t0 处n阶左右导数存在，并且满足</p>
<p><img alt="image-20211210211053205" src="https://pic.tim-wcx.ltd//img/20211210211054.png" /></p>
<p>记为Cn（曲线n阶参数连续）</p>
<p><strong>几何连续性</strong>、</p>
<ol>
<li>0阶几何连续
   称曲线P=P( t ) 在 t=t0 处0阶几何连续，如果它在 t0 处位置连续，即</li>
</ol>
<p><img alt="image-20211210211126556" src="https://pic.tim-wcx.ltd//img/20211210211126.png" /></p>
<p>记为：GC0</p>
<ol>
<li>1阶几何连续
   称曲线 P=P(t) 在 t = t0 处1阶几何连续，如果它在 t0处 GC0 ，并且切矢量方向连续，即</li>
</ol>
<p><img alt="image-20211210211134748" src="https://pic.tim-wcx.ltd//img/20211210211134.png" /></p>
<p>记为： GC1</p>
<p><strong>参数多项式曲线</strong></p>
<ol>
<li>n次多项式曲线</li>
</ol>
<p><img alt="image-20211210211222199" src="https://pic.tim-wcx.ltd//img/20211210211222.png" /></p>
<ol>
<li>矩阵表示</li>
</ol>
<p><img alt="image-20211210211301783" src="https://pic.tim-wcx.ltd//img/20211210211301.png" /></p>
<ol>
<li>加权和形式</li>
</ol>
<p><img alt="image-20211210211316853" src="https://pic.tim-wcx.ltd//img/20211210211316.png" /></p>
<ol>
<li>缺点</li>
</ol>
<p>Pi  没有明显的几何意义。Pi  与曲线的关系不明确，导致曲线的形状控制困难</p>
<ol>
<li>基矩阵表示</li>
</ol>
<p>矩阵分解</p>
<p><span class="arithmatex"><span class="MathJax_Preview">C=G \cdot M</span><script type="math/tex">C=G \cdot M</script></span></p>
<p><span class="arithmatex"><span class="MathJax_Preview">P(t)=G \cdot M \cdot T, t \in [0,1]</span><script type="math/tex">P(t)=G \cdot M \cdot T, t \in [0,1]</script></span></p>
<p>几何矩阵</p>
<div class="codehilite"><pre><span></span><code>$G = [G_0.G_1 … G_n]$ 控制顶点 Gi
</code></pre></div>

<p>基矩阵M：MT 确定了一组基函数</p>
<p>基矩阵决定了多项式曲线的性质</p>
<ol>
<li>绘制方法</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211210212033.png" alt="image-20211210212033682" style="zoom:67%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210212103.png" alt="image-20211210212103557" style="zoom:67%;" /></p>
<p><strong>Bezier基函数</strong></p>
<ol>
<li>定义</li>
</ol>
<p><img alt="image-20211210212333587" src="https://pic.tim-wcx.ltd//img/20211210212333.png" /></p>
<ol>
<li>性质</li>
<li>
<p>正性：<span class="arithmatex"><span class="MathJax_Preview">BEZ_{i,n}(t) \geq 0 ,t \in [0,1]</span><script type="math/tex">BEZ_{i,n}(t) \geq 0 ,t \in [0,1]</script></span></p>
</li>
<li>
<p>权性：<span class="arithmatex"><span class="MathJax_Preview">\sum _{i=0}^n BEZ_{i,n}(t)=1,t \in [0,1 ]</span><script type="math/tex">\sum _{i=0}^n BEZ_{i,n}(t)=1,t \in [0,1 ]</script></span></p>
</li>
<li>
<p>对称性：</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210212740.png" alt="image-20211210212740448" style="zoom:80%;" /></p>
</li>
<li>
<p>降阶公式：</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210212811.png" alt="image-20211210212811857" style="zoom:80%;" /></p>
</li>
<li>
<p>升阶公式</p>
<p><img alt="image-20211210212841755" src="https://pic.tim-wcx.ltd//img/20211210212841.png" /></p>
<p><img alt="image-20211210212928038" src="https://pic.tim-wcx.ltd//img/20211210212928.png" /></p>
</li>
</ol>
<p><strong>BEZier曲线</strong></p>
<ol>
<li>定义</li>
</ol>
<p>如下形式的 n 次多项式称为 n 次 Bezier曲线：</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210213052.png" alt="image-20211210213052459" style="zoom:67%;" /></p>
<p>控制顶点：Pi（i＝0，1，… ， n）</p>
<p>控制多边形： P0P1 … Pn，曲线是控制顶点的加权和 （权是基函数的值）</p>
<ol>
<li>
<p>性质</p>
</li>
<li>
<p>端点性质</p>
<p><img alt="image-20211210213208851" src="https://pic.tim-wcx.ltd//img/20211210213208.png" /></p>
</li>
<li>
<p>端点切矢量</p>
<p><img alt="image-20211210213219578" src="https://pic.tim-wcx.ltd//img/20211210213219.png" /></p>
</li>
<li>
<p>导数曲线</p>
<p><img alt="image-20211210213241360" src="https://pic.tim-wcx.ltd//img/20211210213241.png" /></p>
</li>
<li>
<p>n次Bezier曲线 P(t) 的导数曲线 P’(t) 是 n－1次Bezier曲线</p>
</li>
<li>
<p>仿射不变性</p>
<p>几何性质不随坐标几何变换而变换（形状、曲率等）仿射变换不改变曲线的表示形式。</p>
<p>对Bezier曲线的几何变换只要作用于控制顶点即可。</p>
<p><img alt="image-20211210213330003" src="https://pic.tim-wcx.ltd//img/20211210213330.png" /></p>
</li>
<li>
<p>凸包性</p>
<p>凸集： {Pi}的凸集是指包含这些点的凸多边形</p>
<p>凸包： {Pi}的凸包是指包含这些点的最小凸集</p>
<p>Bezier曲线位于其控制顶点的凸包之内</p>
</li>
<li>
<p>平面曲线的保型性</p>
<p>保凸性：如果多边形是凸的，那么Bezier曲线也是凸的</p>
<p>变差缩减性：平面内任一直线与Bezier曲线的交点个数不多于该直线与控制多边形的交点个数。说明Bezier曲线比控制多边形的波动小，更光顺</p>
</li>
<li>
<p>拟局部性
      局部性指移动控一个制顶点时，只影响曲线的局部。</p>
</li>
<li>
<p>移动控制顶点Pi 时，对应参数 t＝i /n 的曲线上的点变动最大，远离 i/n 的曲线上的点变动越来越小</p>
</li>
<li>
<p>一次Bezier曲线</p>
</li>
</ol>
<p>n = 1时，有两个控制点 P0 和 P1 ，Bezier多项式是一次多项式：</p>
<p><img alt="image-20211210213619482" src="https://pic.tim-wcx.ltd//img/20211210213619.png" /></p>
<p>一次Bezier曲线是连接起点P0和终点P1的直线段</p>
<ol>
<li>二次Bezier曲线</li>
</ol>
<p>n=2时，有3个控制点P0、P1和P2，Bezier多项式是二次多项式：</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210213651.png" alt="image-20211210213651318" style="zoom: 80%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210213701.png" alt="image-20211210213701470" style="zoom:80%;" /></p>
<ol>
<li>三次Bezier曲线</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211210213913.png" alt="image-20211210213912958" style="zoom:67%;" /></p>
<p><strong>三次Hermite(厄密多)曲线</strong></p>
<ol>
<li>给定4个矢量P0, P1, R0, R1 ，称满足下列条件的三次多项式曲线 P(t) 为Hermite 曲线</li>
</ol>
<p><img alt="image-20211210215148897" src="https://pic.tim-wcx.ltd//img/20211210215148.png" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210215158.png" alt="image-20211210215158915" style="zoom:67%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210215334.png" alt="image-20211210215334519" style="zoom:67%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210215357.png" alt="image-20211210215357468" style="zoom:80%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210215438.png" alt="image-20211210215438272" style="zoom:67%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210215538.png" alt="image-20211210215538778" style="zoom:80%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210215607.png" alt="image-20211210215607674" style="zoom:67%;" /></p>
<p><strong>Bezier曲线的离散生成算法</strong></p>
<ol>
<li>Horner算法</li>
</ol>
<p>只适宜低次Bezier曲线（如三次Bezier曲线）</p>
<ol>
<li>de  Casteljau(德 · 卡斯特里奥)算法</li>
</ol>
<p><img src="https://pic.tim-wcx.ltd//img/20211210214312.png" alt="image-20211210214312228" style="zoom:80%;" /></p>
<p>可用Bezier降阶公式证明</p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210220825.png" alt="image-20211210220824688" style="zoom:67%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210220850.png" alt="image-20211210220850059" style="zoom:67%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210220904.png" alt="image-20211210220904054" style="zoom:67%;" /></p>
<p><img src="https://pic.tim-wcx.ltd//img/20211210220911.png" alt="image-20211210220911475" style="zoom:67%;" /></p>
<p><strong>Bezier曲面</strong></p>
<p>定义：利用两组正交的 Bezier 曲线逼近由控制点网格描述的曲面</p>
<p><img alt="image-20211210221059058" src="https://pic.tim-wcx.ltd//img/20211210221059.png" /></p>
<p>其中 pj, k 是给定的 (m+1)×(n+1) 个控制点的位置</p>
<p>Bezier 曲面与 Bezier 曲线有相同的性质</p>





                
              </article>
            </div>
          
          
        </div>
        
          <button type="button" class="md-top md-icon" data-md-component="top" hidden>
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12Z"/></svg>
            回到页面顶部
          </button>
        
      </main>
      
        <footer class="md-footer">
  
    
      
      <nav class="md-footer__inner md-grid" aria-label="页脚" >
        
          
          <a href="../%E8%BD%AF%E4%BB%B6%E5%B7%A5%E7%A8%8B/" class="md-footer__link md-footer__link--prev" aria-label="上一页: 软件工程" rel="prev">
            <div class="md-footer__button md-icon">
              <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
            </div>
            <div class="md-footer__title">
              <span class="md-footer__direction">
                上一页
              </span>
              <div class="md-ellipsis">
                软件工程
              </div>
            </div>
          </a>
        
        
          
          <a href="../%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/" class="md-footer__link md-footer__link--next" aria-label="下一页: 计算机操作系统" rel="next">
            <div class="md-footer__title">
              <span class="md-footer__direction">
                下一页
              </span>
              <div class="md-ellipsis">
                计算机操作系统
              </div>
            </div>
            <div class="md-footer__button md-icon">
              <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4Z"/></svg>
            </div>
          </a>
        
      </nav>
    
  
  <div class="md-footer-meta md-typeset">
    <div class="md-footer-meta__inner md-grid">
      <div class="md-copyright">
  
  
    Made with
    <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
      Material for MkDocs
    </a>
  
</div>
      
    </div>
  </div>
</footer>
      
    </div>
    <div class="md-dialog" data-md-component="dialog">
      <div class="md-dialog__inner md-typeset"></div>
    </div>
    
    <script id="__config" type="application/json">{"base": "../..", "features": ["navigation.tabs", "navigation.top", "navigation.footer", "content.code.copy", "content.code.select", "content.code.annotate"], "search": "../../assets/javascripts/workers/search.208ed371.min.js", "translations": {"clipboard.copied": "\u5df2\u590d\u5236", "clipboard.copy": "\u590d\u5236", "search.result.more.one": "\u5728\u8be5\u9875\u4e0a\u8fd8\u6709 1 \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.more.other": "\u5728\u8be5\u9875\u4e0a\u8fd8\u6709 # \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.none": "\u6ca1\u6709\u627e\u5230\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.one": "\u627e\u5230 1 \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.other": "# \u4e2a\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c", "search.result.placeholder": "\u952e\u5165\u4ee5\u5f00\u59cb\u641c\u7d22", "search.result.term.missing": "\u7f3a\u5c11", "select.version": "\u9009\u62e9\u5f53\u524d\u7248\u672c"}}</script>
    
    
      <script src="../../assets/javascripts/bundle.b4d07000.min.js"></script>
      
        <script src="../../js/extra.js"></script>
      
        <script src="../../js/baidu-tongji.js"></script>
      
        <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML"></script>
      
    
  </body>
</html>